Skip to main content

Module arena

Module arena 

Source
Expand description

Block-based arena allocator with bulk deallocation.

An ArenaAllocator tracks every individual allocation in a singly-linked list of [Header]–prefixed blocks. Each call to alloc allocates a fresh block from the backing allocator; dealloc is a deliberate no-op. All memory is reclaimed at once via reset or when the arena is dropped.

§Trade-offs

ProCon
Individual allocations are very cheapEach allocation has a Header overhead
Bulk free is O(n) in number of allocationsdealloc is a no-op — no reuse within a cycle
Works with any backing AllocatorNot thread-safe (Cell internals)

§Example

let sys = SystemAllocator;
let arena = ArenaAllocator::new(&sys);
let vec: ExVec<u32> = ExVec::new(&arena);
// ... use vec ...
arena.reset(); // frees everything at once

Structs§

ArenaAllocator
A block-based allocator that frees all memory at once.

Traits§

ArenaExt
Extension trait that adds zeroed allocation to arena-like allocators.