![]() |
XII Release 0.1.0
|
#include <LargeBlockAllocator.h>
Public Member Functions | |
| xiiLargeBlockAllocator (xiiStringView sName, xiiAllocator *pParent, xiiAllocatorTrackingMode mode=xiiAllocatorTrackingMode::Default) | |
| template<typename T> | |
| xiiDataBlock< T, BlockSizeInByte > | AllocateBlock () |
| template<typename T> | |
| void | DeallocateBlock (xiiDataBlock< T, BlockSizeInByte > &ref_block) |
| Deallocates a previously allocated block. | |
| xiiStringView | GetName () const |
| Returns the name of this allocator instance. | |
| xiiAllocatorId | GetId () const |
| Returns the unique identifier for this allocator instance. | |
| const xiiAllocator::Stats & | GetStats () const |
| template<typename T> | |
| XII_FORCE_INLINE xiiDataBlock< T, BlockSize > | AllocateBlock () |
| template<typename T> | |
| XII_FORCE_INLINE void | DeallocateBlock (xiiDataBlock< 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:
| xiiDataBlock< T, BlockSizeInByte > xiiLargeBlockAllocator< 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()).