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
| Pro | Con |
|---|---|
| Individual allocations are very cheap | Each allocation has a Header overhead |
| Bulk free is O(n) in number of allocations | dealloc is a no-op — no reuse within a cycle |
Works with any backing Allocator | Not 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 onceStructs§
- Arena
Allocator - A block-based allocator that frees all memory at once.
Traits§
- Arena
Ext - Extension trait that adds zeroed allocation to arena-like allocators.