A memory pool that can allocate objects of a single type very quickly. Use this when you need to allocate a lot of objects of the same type, because It outperforms general purpose allocators.
Functions
fn destroy(pool: *Pool, ptr: ItemPtr) void
Destroys a previously created item. Only pass items to
ptr
that were previous…Destroys a previously created item. Only pass items to
ptr
that were previously created withcreate()
of the same memory pool!fn initPreheated(allocator: std.mem.Allocator, initial_size: usize) MemoryPoolError!Pool
Creates a new memory pool and pre-allocates
initial_size
items. This allows t…Creates a new memory pool and pre-allocates
initial_size
items. This allows the up toinitial_size
active allocations before aOutOfMemory
error happens when callingcreate()
.
Values
item_alignment | type | Alignment of the memory pool items. This is not necessarily the same as `@align… |
item_size | type | Size of the memory pool items. This is not necessarily the same as `@sizeOf(Ite… |