Navigation
API > API/Runtime > API/Runtime/Engine
Allocator for spans from some range that is allowed to grow and shrink to accomodate the allocations. Implementation is biased towards the case where allocations and frees are performed in bulk, if they are interleaved performance will degrade. Prefers allocations at the start of the range, such that the high-watermark can be reduced optimally. Primarily optimized for the use-case where span size == 1, for variable span size allocation performance is sub-optimal as it does not accelerate the search for larger allocs.
| Name | FSpanAllocator |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Public/SpanAllocator.h |
| Include Path | #include "SpanAllocator.h" |
Syntax
class FSpanAllocator
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FSpanAllocator
(
bool bInGrowOnly |
If bInGrowOnly is true the size reported by GetMaxSize() will never decrease except when for when Reset() or Empty() is called. | SpanAllocator.h |
Structs
| Name | Remarks |
|---|---|
| FLinearAllocation |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bGrowOnly | bool | SpanAllocator.h | ||
| CurrentMaxSize | int32 | Size of the linear range used by the allocator. | SpanAllocator.h | |
| CurrentSize | int32 | Total of number of items currently allocated. | SpanAllocator.h | |
| FirstNonEmptySpan | int32 | First span in free list that is not empty, used to speed up search for free items. | SpanAllocator.h | |
| FreeSpans | TArray< FLinearAllocation, TInlineAllocator< 10 > > | Ordered free list from low to high. | SpanAllocator.h | |
| PeakMaxSize | int32 | Peak tracked size since last Reset or Empty. | SpanAllocator.h | |
| PendingFreeSpans | TArray< FLinearAllocation, TInlineAllocator< 10 > > | Unordered list of freed items since last consolidate. | SpanAllocator.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
int32 Allocate
(
int32 Num |
Allocate a range. Returns allocated StartOffset. | SpanAllocator.h | |
void Consolidate () |
Between these calls to Free just appends the allocation to the free list, rather than trying to merge with existing allocations. | SpanAllocator.h | |
void Empty() |
SpanAllocator.h | ||
void Free
(
int32 BaseOffset, |
Free an already allocated range. | SpanAllocator.h | |
SIZE_T GetAllocatedSize() |
SpanAllocator.h | ||
int32 GetMaxSize() |
SpanAllocator.h | ||
int32 GetNumFreeSpans() |
SpanAllocator.h | ||
int32 GetNumPendingFreeSpans() |
SpanAllocator.h | ||
int32 GetSparselyAllocatedSize() |
SpanAllocator.h | ||
bool IsFree
(
int32 Index |
Loop over all free spans and check if Index is in any of them. | SpanAllocator.h | |
void Reset() |
SpanAllocator.h |