Arena Spec
Arena Behavoir Time 0: Arena created - Main memory: [empty, capacity=1000] - Freelist: [sentinel only] - Allocation: Uses fast path ✓ Time 1: Allocate 300 bytes - Main memory: [used=300, remaining=700] - Freelist: [sentinel only] - Allocation: Uses fast path ✓ Time 2: Allocate 500 bytes - Main memory: [used=800, remaining=200] - Freelist: [sentinel only] - Allocation: Uses fast path ✓ Time 3: Drop the 300-byte allocation - Main memory: [used=800, remaining=200] - Freelist: [sentinel → 300-byte segment] - Now freelist has 1 usable segment! Time 4: Allocate 400 bytes (main memory too small) - Fast path fails (want=1200 > cap=1000) - Slow path: Uses 300-byte segment from freelist ✓ Core Data Structures 1. Memory Region A contiguous block of memory (from heap allocation, file mapping, or anonymous mapping) Divided into: Reserved Space → Metadata/Header → Allocation Space Base pointer anchors all address calculations using relative offsets. 2. Header (Allocation State) Tracks current allocation position (monotonically increasing) ...