![]() |
ezEngine Release 26.3
|
Specialized allocator for fixed-size memory blocks, optimized for bulk allocations. More...
#include <LargeBlockAllocator.h>
Public Member Functions | |
| ezLargeBlockAllocator (ezStringView sName, ezAllocator *pParent, ezAllocatorTrackingMode mode=ezAllocatorTrackingMode::Default) | |
| template<typename T > | |
| ezDataBlock< T, BlockSizeInByte > | AllocateBlock () |
| Allocates a new typed block capable of holding elements of type T. | |
| template<typename T > | |
| void | DeallocateBlock (ezDataBlock< T, BlockSizeInByte > &ref_block) |
| Deallocates a previously allocated block. | |
| ezStringView | GetName () const |
| ezAllocatorId | GetId () const |
| Returns the unique identifier for this allocator instance. | |
| const ezAllocator::Stats & | GetStats () const |
| template<typename T > | |
| EZ_FORCE_INLINE ezDataBlock< T, BlockSize > | AllocateBlock () |
| template<typename T > | |
| EZ_FORCE_INLINE void | DeallocateBlock (ezDataBlock< T, BlockSize > &inout_block) |
Specialized allocator for fixed-size memory blocks, optimized for bulk allocations.
This allocator manages memory in large chunks called "SuperBlocks" (16 blocks each) and provides individual blocks of the specified size on demand. It's designed for scenarios where you need many identically-sized allocations with good spatial locality.
SuperBlock strategy reduces fragmentation and improves cache performance by grouping related allocations together. When blocks are freed, they're added to a free list for immediate reuse without returning memory to the OS.
Best used for:
| ezDataBlock< T, BlockSizeInByte > ezLargeBlockAllocator< BlockSizeInByte >::AllocateBlock | ( | ) |
Allocates a new typed block capable of holding elements of type T.
Returns a typed wrapper around a raw memory block. The block can hold BlockSizeInByte / sizeof(T) elements. If allocation fails, returns an invalid block (check with IsEmpty()).