ezEngine Release 26.3
Loading...
Searching...
No Matches
ezLargeBlockAllocator< BlockSizeInByte > Class Template Reference

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::StatsGetStats () const
 
template<typename T >
EZ_FORCE_INLINE ezDataBlock< T, BlockSize > AllocateBlock ()
 
template<typename T >
EZ_FORCE_INLINE void DeallocateBlock (ezDataBlock< T, BlockSize > &inout_block)
 

Detailed Description

template<ezUInt32 BlockSizeInByte>
class ezLargeBlockAllocator< BlockSizeInByte >

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:

  • Object pools where objects have uniform size
  • Bulk allocations for data structures like arrays or strings
  • Memory regions that benefit from spatial locality

Member Function Documentation

◆ AllocateBlock()

template<ezUInt32 BlockSizeInByte>
template<typename T >
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()).


The documentation for this class was generated from the following files: