![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <GenericPlatformMemory.h>
Inheritance diagram for FGenericPlatformMemory:Classes | |
| class | FBasicVirtualMemoryBlock |
| struct | FSharedMemoryRegion |
Public Types | |
| enum | EMemoryCounterRegion { MCR_Invalid , MCR_Physical , MCR_GPU , MCR_GPUSystem , MCR_TexturePool , MCR_StreamingPool , MCR_UsedStreamingPool , MCR_GPUDefragPool , MCR_PhysicalLLM , MCR_MAX } |
| enum | EMemoryAllocatorToUse { Ansi , Stomp , TBB , Jemalloc , Binned , Binned2 , Binned3 , Platform , Mimalloc , Libpas } |
| enum | ESharedMemoryAccess { Read = (1 << 1) , Write = (1 << 2) } |
Static Public Attributes | |
| static CORE_API bool | bIsOOM = false |
| static CORE_API uint64 | OOMAllocationSize = 0 |
| static CORE_API uint32 | OOMAllocationAlignment = 0 |
| static CORE_API void * | BackupOOMMemoryPool = nullptr |
| static CORE_API uint32 | BackupOOMMemoryPoolSize |
| static CORE_API EMemoryAllocatorToUse | AllocatorToUse = Platform |
Generic implementation for most platforms, these tend to be unused and unimplemented.
Various memory regions that can be used with memory stats. The exact meaning of the enums are relatively platform-dependent, although the general ones (Physical, GPU) are straightforward. A platform can add more of these, and it won't affect other platforms, other than a minuscule amount of memory for the StatManager to track the max available memory for each region (uses an array FPlatformMemory::MCR_MAX big)
| Enumerator | |
|---|---|
| MCR_Invalid | |
| MCR_Physical | |
| MCR_GPU | |
| MCR_GPUSystem | |
| MCR_TexturePool | |
| MCR_StreamingPool | |
| MCR_UsedStreamingPool | |
| MCR_GPUDefragPool | |
| MCR_PhysicalLLM | |
| MCR_MAX | |
|
static |
|
inlinestatic |
Memcpy optimized for big blocks.
Allocates pages from the OS.
| Size | Size to allocate, not necessarily aligned |
Returns pages allocated by BinnedAllocFromOS to the OS.
| A | pointer previously returned from BinnedAllocFromOS |
| Size | size of the allocation previously passed to BinnedAllocFromOS |
|
inlinestatic |
Some platforms may pool allocations of this size to reduce OS calls. This function serves as a hint for BinnedMalloc's CachedOSPageAllocator so it does not cache these allocations additionally
|
inlinestatic |
Return true if the platform can allocate a lot more virtual memory than physical memory It's true for most platforms, but iOS needs a special entitlement and Linux a kernel config for this
|
static |
Dumps basic platform memory statistics and allocator specific statistics into the specified output device.
|
static |
Dumps basic platform memory statistics into the specified output device.
|
static |
|
static |
Returns >0 if debug memory has been assigned to the title for general use. Only applies to platforms with fixed memory and no paging.
|
inlinestatic |
Return the page allocations from the operating system (/proc/self/smaps). This only means something on platforms that can fork and have Copy On Write behavior.
|
static |
This function sets AllocFunction and FreeFunction and returns true, or just returns false. These functions are the platform dependant low low low level functions that LLM uses to allocate memory.
|
static |
Return which "high level", per platform, memory bucket we are in
|
static |
|
static |
Returns initial program size or 0 if the platform doesn't track initial program size
|
static |
|
static |
Writes all platform specific current memory statistics in the format usable by the malloc profiler.
|
static |
Returns true if Protecting the parent processes pages has been enabled Only supported on platforms that support forking
|
static |
Initializes platform memory specific constants.
|
staticprotected |
Updates platform specific stats. This method is called through FGenericStatsUpdater from the task graph thread.
|
static |
Returns true if debug memory has been assigned to the title for general use. Only applies to platforms with fixed memory and no paging.
Nano Malloc is Apple's tiny block allocator. Does the Nano malloc zone exist?
|
static |
Maps a named shared memory region into process address space (creates or opens it)
| Name | unique name of the shared memory region (should not contain [back]slashes to remain cross-platform). |
| bCreate | whether we're creating it or just opening existing (created by some other process). |
| AccessMode | mode which we will be accessing it (use values from ESharedMemoryAccess) |
| Size | size of the buffer (should be >0. Also, the real size is subject to platform limitations and may be increased to match page size) |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Copies count bytes of characters from Src to Dest. If some regions of the source area and the destination overlap, memmove ensures that the original source bytes in the overlapping region are copied before being overwritten. NOTE: make sure that the destination buffer is the same size or larger than the source buffer!
|
inlinestatic |
|
inlinestatic |
Performs initial setup for MiMalloc. This is a noop on platforms that do not support MiMalloc, or when MIMALLOC_ENABLED is not defined.
Performs initial setup for Nano malloc. This is a noop on non-apple platforms
|
inlinestatic |
Called for all default tracker LLM allocations and frees, when LLM is enabled. Provides a single alloc/free hook that platforms can implement to support platform specific memory analysis tools.
|
inlinestatic |
|
static |
Changes the protection on a region of committed pages in the virtual address space.
| Ptr | Address to the starting page of the region of pages whose access protection attributes are to be changed. |
| Size | The size of the region whose access protection attributes are to be changed, in bytes. |
| bCanRead | Can the memory be read. |
| bCanWrite | Can the memory be written to. |
|
inlinestatic |
On some platforms memcpy can be distributed over multiple threads for throughput.
|
static |
Returns a pretty-string for an amount of memory given in bytes.
| Memory | amount in bytes |
Was this pointer allocated by in the Nano Malloc Zone? Currently only Apple platforms implement this to detect small block allocations.
| The | pointer to query |
Was this pointer allocated by the OS malloc? Currently only Apple platforms implement this to detect small block allocations.
| The | pointer to query |
|
inlinestatic |
Loads a simple POD type from unaligned memory.
| Ptr | unaligned memory of at least size sizeof(T) |
Called once at LLM initialization time to let the platform add any custom tags
Sets the initial program size
|
static |
Initializes the memory pools, should be called by the init function.
|
inlinestatic |
On some platforms memcpy optimized for big blocks that avoid L2 cache pollution are available
|
inlinestatic |
Gets whether this platform supports Fast VRAM memory Ie, whether TexCreate_FastVRAM flags actually mean something or not
Indicates whether LLM allocations are already accounted for with tracking and in GetStats. Returns true if LLM allocations come from a memory pool separate from the main engine's memory or are already tagged with tracking by the platform memory system. Returns false if LLM uses the regular memory shared with the engine and allocations are not tracked.
|
static |
Unmaps a name shared memory region
| MemoryRegion | an object that encapsulates a shared memory region (will be destroyed even if function fails!) |
Called once per frame when LLM is collating the data for the current frame. Can be used to set platform-specific calculated tag data via SetTagAmountForTracker
|
inlinestatic |
Stores a simple POD type to unaligned memory.
| Ptr | unaligned memory of at least size sizeof(T) |
| Value | value to write at Ptr |
|
friend |
|
static |
Current allocator
|
static |
Preallocated buffer to delete on out of memory. Used by OOM handling and crash reporting.
Size of BackupOOMMemoryPool in bytes.
|
static |
Set to alignment of allocation that triggered out of memory, zero otherwise.
|
static |
Set to size of allocation that triggered out of memory, zero otherwise.
|
staticprotected |
Program memory allocation in bytes.