UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FSpanAllocator Class Reference

#include <SpanAllocator.h>

Public Member Functions

ENGINE_API FSpanAllocator (bool bInGrowOnly=false)
 
int32 Allocate (int32 Num=1)
 
void Free (int32 BaseOffset, int32 Num=1)
 
ENGINE_API void Reset ()
 
ENGINE_API void Empty ()
 
int32 GetSparselyAllocatedSize () const
 
int32 GetMaxSize () const
 
int32 GetNumFreeSpans () const
 
int32 GetNumPendingFreeSpans () const
 
SIZE_T GetAllocatedSize () const
 
ENGINE_API void Consolidate ()
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ FSpanAllocator()

FSpanAllocator::FSpanAllocator ( bool  bInGrowOnly = false)

If bInGrowOnly is true the size reported by GetMaxSize() will never decrease except when for when Reset() or Empty() is called.

Member Function Documentation

◆ Allocate()

int32 FSpanAllocator::Allocate ( int32  Num = 1)
inline

◆ Consolidate()

void FSpanAllocator::Consolidate ( )

Between these calls to Free just appends the allocation to the free list, rather than trying to merge with existing allocations. At EndDeferMerges the free list is consolidated by sorting and merging all spans. This amortises the cost of the merge over many calls.

◆ Empty()

void FSpanAllocator::Empty ( )

◆ Free()

void FSpanAllocator::Free ( int32  BaseOffset,
int32  Num = 1 
)
inline

◆ GetAllocatedSize()

SIZE_T FSpanAllocator::GetAllocatedSize ( ) const
inline

◆ GetMaxSize()

int32 FSpanAllocator::GetMaxSize ( ) const
inline

◆ GetNumFreeSpans()

int32 FSpanAllocator::GetNumFreeSpans ( ) const
inline

◆ GetNumPendingFreeSpans()

int32 FSpanAllocator::GetNumPendingFreeSpans ( ) const
inline

◆ GetSparselyAllocatedSize()

int32 FSpanAllocator::GetSparselyAllocatedSize ( ) const
inline

◆ Reset()

void FSpanAllocator::Reset ( )

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