Navigation
Unreal Engine C++ API Reference > Runtime > Core > Memory
References
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Memory/VirtualStackAllocator.h |
Include | #include "Memory/VirtualStackAllocator.h" |
Syntax
enum EVirtualStackAllocatorDecommitMode
{
AllOnDestruction = 0,
AllOnStackEmpty = 1,
ExcessOnStackEmpty = 2,
NumModes,
}
Values
Name | Description |
---|---|
AllOnDestruction | Default mode, does not decommit pages until the allocator is destroyed. |
AllOnStackEmpty | Decommits all pages once none are in use. |
ExcessOnStackEmpty | Tracks the high water mark and uses it to free excess memory that is not expected to be used again soon This enables us to quickly release memory consumed by a one-off spikey usage pattern while avoiding frequent page management in the steady state See DecommitUnusedPages() for details of the heuristic used |
NumModes |
Remarks
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