Arena Allocators

An arena (aka bump allocator or region allocator) pre-allocates a large block and hands out sequential chunks by bumping a pointer. Frees happen all at once when the arena is destroyed — no individual free() calls. Advantages: allocation is O(1) (just bump), no fragmentation, cache-friendly, trivial to implement (~30 lines). Disadvantage: can’t free individual objects. Perfect for: parsers, compilers, game frames, request handlers — any scope where you allocate many small objects and discard them together.

Appears In

m03-dynamic-memory