![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <AllocatorFixedSizeFreeList.h>
Public Member Functions | |
| TAllocatorFixedSizeFreeList (uint32 InitialBlockSize=0) | |
| ~TAllocatorFixedSizeFreeList () | |
| void * | Allocate () |
| void | Free (void *Element) |
| uint32 | GetAllocatedSize () const |
| void | Grow (uint32 NumElements) |
Fixed-sized allocator that uses a free list to cache allocations. Initial allocation block can be specified in the ctor to warm the cache. Subsequent allocations are in multiples of the given blocksize.
Grow can be called at any time to warm the cache with a single block allocation. Initial allocation will want to be a reasonable guess as to how big the pool might grow. BlockSize should be small enough to cut down on allocations but not overcommit memory.
NOTE: Currently there is not way to flush the pool because it doesn't track each block's allocation status.
Not threadsafe <could be implemented using a ThreadingPolicy template parameter>.
Template params: AllocationSize - size of each allocation (must be at least as large as a pointer) BlockSize - number of allocations to reserve room for when a new block needs to be allocated.
|
inline |
Ctor
| InitialBlockSize | - number of allocations to warm the cache with |
|
inline |
Destructor. Can't free memory, so only checks that allocations have been returned.
|
inline |
Allocates one element from the free list. Return it by calling Free.
|
inline |
Returns one element from the free list. Must have been acquired previously by Allocate.
|
inline |
Get total memory allocated. Only returns the size of allocations made directly by the allocator, not the elements themselves.
|
inline |
Grows the free list by a specific number of elements. Does one allocation for all elements. Safe to call at any time to warm the cache with a single block allocation.