Navigation
API > API/Runtime > API/Runtime/Core
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
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.
| Name | TAllocatorFixedSizeFreeList |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/AllocatorFixedSizeFreeList.h |
| Include Path | #include "Containers/AllocatorFixedSizeFreeList.h" |
Syntax
template<uint32 AllocationSize, uint32 BlockSize>
class TAllocatorFixedSizeFreeList
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TAllocatorFixedSizeFreeList
(
uint32 InitialBlockSize |
Ctor | Containers/AllocatorFixedSizeFreeList.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TAllocatorFixedSizeFreeList() |
Destructor. Can't free memory, so only checks that allocations have been returned. | Containers/AllocatorFixedSizeFreeList.h |
Structs
| Name | Remarks |
|---|---|
| FreeListNode |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| FreeList | FreeListNode * | Linked List of free memory blocks. | Containers/AllocatorFixedSizeFreeList.h | |
| NumAllocated | uint32 | The number of objects that have been allocated. | Containers/AllocatorFixedSizeFreeList.h | |
| NumLive | uint32 | The number of objects that are constructed and "out in the wild". | Containers/AllocatorFixedSizeFreeList.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void * Allocate() |
Allocates one element from the free list. Return it by calling Free. | Containers/AllocatorFixedSizeFreeList.h | |
void Free
(
void* Element |
Returns one element from the free list. Must have been acquired previously by Allocate. | Containers/AllocatorFixedSizeFreeList.h | |
uint32 GetAllocatedSize () |
Get total memory allocated. | Containers/AllocatorFixedSizeFreeList.h | |
void Grow
(
uint32 NumElements |
Grows the free list by a specific number of elements. | Containers/AllocatorFixedSizeFreeList.h |