TAllocatorFixedSizeFreeList

Fixed-sized allocator that uses a free list to cache allocations.

Windows
MacOS
Linux

Syntax

template<uint32 AllocationSize, uint32 BlockSize>
class TAllocatorFixedSizeFreeList

Remarks

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.

Constructors

Name Description

Public function

TAllocatorFixedSizeFreeList

(
    uint32 InitialBlockSize
)

Ctor

Destructors

Name Description

Public function

~TAllocatorFixedSizeFreeList()

Destructor. Can't free memory, so only checks that allocations have been returned.

Functions

Name Description

Public function

void *

 

Allocate()

Allocates one element from the free list. Return it by calling Free.

Public function

void

 

Free

(
    void* Element
)

Returns one element from the free list. Must have been acquired previously by Allocate.

Public function Const

uint32

 

GetAllocatedSize()

Get total memory allocated.

Public function

void

 

Grow

(
    uint32 NumElements
)

Grows the free list by a specific number of elements.

References

Module

Core

Header

Runtime/Core/Public/Containers/AllocatorFixedSizeFreeList.h

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback