fn MemoryPoolExtra(comptime Item: type, comptime pool_options: Options) type

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.

Parameters

Item: type,
pool_options: Options,

Fields

free_list: ?NodePtr = null,

Functions

fn create(pool: *Pool) !ItemPtr

Creates a new item and adds it to the memory pool.

fn deinit(pool: *Pool) void

Destroys the memory pool and frees all allocated memory.

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 with create() of the same memory pool!

fn init(allocator: std.mem.Allocator) Pool

Creates a new 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 to initial_size active allocations before a OutOfMemory error happens when calling create().

fn reset(pool: *Pool) void

Resets the memory pool and destroys all allocated items. This can be used to ba…

Resets the memory pool and destroys all allocated items. This can be used to batch-destroy all objects without invalidating the memory pool.

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…