UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VirtualStackAllocator.h File Reference
#include "HAL/Platform.h"
#include "HAL/PlatformCrt.h"
#include "HAL/PlatformMemory.h"
#include "Misc/AssertionMacros.h"
#include "AutoRTFM.h"

Go to the source code of this file.

Classes

struct  FScopedStackAllocatorBookmark
 
class  FVirtualStackAllocator
 

Enumerations

enum class  EVirtualStackAllocatorDecommitMode : uint8 { AllOnDestruction = 0 , AllOnStackEmpty = 1 , ExcessOnStackEmpty = 2 , NumModes }
 

Enumeration Type Documentation

◆ EVirtualStackAllocatorDecommitMode

Implements a stack-style allocator backed by a dedicated block of virtual memory

FVirtualStackAllocator provides the ability to reserve a block of virtual memory and handles the allocation process

Freeing memory is handled by FScopedStackAllocatorBookmark which will, upon destruction, free all memory that was allocated after its creation.

To use the system, first create a FVirtualStackAllocator with a lifetime longer than any allocations you will make from it. In each scope that you would like be able to bulk free allocations, create an FScopedStackAllocatorBookmark by calling Allocator->CreateScopedBookmark() Make one or more allocations in any nested scope by calling Allocator->Allocate(Size, Alignment) When the FScopedStackAllocatorBookmark is destructed, all memory allocated after that will be freed back to the allocator

FVirtualStackAllocator provides a one page guard at the end of its reservation to protect against overruns. The total usable memory is therefore NextMultipleOf(ReqestedStackSize, SystemPageSize) - SystemPageSize

Enumerator
AllOnDestruction 
AllOnStackEmpty 
ExcessOnStackEmpty 
NumModes