UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FMemory Struct Reference

#include <UnrealMemory.h>

Public Types

enum  AllocationHints {
  None = -1 , Default , Temporary , SmallPool ,
  Max
}
 

Memory functions (wrapper for FPlatformMemory)

uint32 Alignment = DEFAULT_ALIGNMENT)
 
SIZE_T Count
 
SIZE_T uint32 Alignment = DEFAULT_ALIGNMENT)
 
static UE_FORCEINLINE_HINT voidMemmove (void *Dest, const void *Src, SIZE_T Count)
 
static UE_FORCEINLINE_HINT int32 Memcmp (const void *Buf1, const void *Buf2, SIZE_T Count)
 
static UE_FORCEINLINE_HINT voidMemset (void *Dest, uint8 Char, SIZE_T Count)
 
template<class T >
static void Memset (T &Src, uint8 ValueToSet)
 
static UE_FORCEINLINE_HINT voidMemzero (void *Dest, SIZE_T Count)
 
static bool MemIsZero (const void *Ptr, SIZE_T Count)
 
template<class T >
static void Memzero (T &Src)
 
static UE_FORCEINLINE_HINT voidMemcpy (void *Dest, const void *Src, SIZE_T Count)
 
template<class T >
static void Memcpy (T &Dest, const T &Src)
 
static UE_FORCEINLINE_HINT voidBigBlockMemcpy (void *Dest, const void *Src, SIZE_T Count)
 
static UE_FORCEINLINE_HINT voidStreamingMemcpy (void *Dest, const void *Src, SIZE_T Count)
 
static UE_FORCEINLINE_HINT voidParallelMemcpy (void *Dest, const void *Src, SIZE_T Count, EMemcpyCachePolicy Policy=EMemcpyCachePolicy::StoreCached)
 
static UE_FORCEINLINE_HINT void Memswap (void *Ptr1, void *Ptr2, SIZE_T Size)
 
static void SystemFree (void *Ptr)
 
static FORCENOINLINE CORE_API void Free (void *Original)
 
static FORCENOINLINE CORE_API SIZE_T GetAllocSize (void *Original)
 
static FORCENOINLINE CORE_API SIZE_T QuantizeSize (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
static CORE_API void Trim (bool bTrimThreadCaches=true)
 
static CORE_API void SetupTLSCachesOnCurrentThread ()
 
static CORE_API void ClearAndDisableTLSCachesOnCurrentThread ()
 
static CORE_API void MarkTLSCachesAsUsedOnCurrentThread ()
 
static CORE_API void MarkTLSCachesAsUnusedOnCurrentThread ()
 
static CORE_API void TestMemory ()
 
static CORE_API void EnablePurgatoryTests ()
 
static CORE_API void EnablePoisonTests ()
 
static CORE_API void ExplicitInit (FMalloc &Allocator)
 
static CORE_API voidMallocExternal (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
static CORE_API voidReallocExternal (void *Original, SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
static CORE_API void FreeExternal (void *Original)
 
static CORE_API SIZE_T GetAllocSizeExternal (void *Original)
 
static CORE_API voidMallocZeroedExternal (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
static CORE_API SIZE_T QuantizeSizeExternal (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
 UE_ALLOCATION_FUNCTION (1) static inline void *SystemMalloc(SIZE_T Size)
 
 UE_ALLOCATION_FUNCTION (1, 2) static FORCENOINLINE CORE_API void *Malloc(SIZE_T Count
 
 UE_ALLOCATION_FUNCTION (2, 3) static FORCENOINLINE CORE_API void *Realloc(void *Original
 
 UE_ALLOCATION_FUNCTION (1, 2) static FORCENOINLINE CORE_API void *MallocZeroed(SIZE_T Count
 

Member Enumeration Documentation

◆ AllocationHints

Some allocators can be given hints to treat allocations differently depending on how the memory is used, it's lifetime etc.

Enumerator
None 
Default 
Temporary 
SmallPool 
Max 

Member Function Documentation

◆ BigBlockMemcpy()

static UE_FORCEINLINE_HINT void * FMemory::BigBlockMemcpy ( void Dest,
const void Src,
SIZE_T  Count 
)
inlinestatic

◆ ClearAndDisableTLSCachesOnCurrentThread()

void FMemory::ClearAndDisableTLSCachesOnCurrentThread ( )
static

Clears the TLS caches on the current thread and disables any future caching.

◆ EnablePoisonTests()

void FMemory::EnablePoisonTests ( )
static

Called once main is started and we have -poisonmallocproxy.

◆ EnablePurgatoryTests()

void FMemory::EnablePurgatoryTests ( )
static

Called once main is started and we have -purgatorymallocproxy. This uses the purgatory malloc proxy to check if things are writing to stale pointers.

◆ ExplicitInit()

void FMemory::ExplicitInit ( FMalloc Allocator)
static

Set global allocator instead of creating it lazily on first allocation. Must only be called once and only if lazy init is disabled via a macro.

◆ Free()

void FMemory::Free ( void Original)
static

◆ FreeExternal()

void FMemory::FreeExternal ( void Original)
static

◆ GetAllocSize()

SIZE_T FMemory::GetAllocSize ( void Original)
static

◆ GetAllocSizeExternal()

SIZE_T FMemory::GetAllocSizeExternal ( void Original)
static

◆ MallocExternal()

void * FMemory::MallocExternal ( SIZE_T  Count,
uint32  Alignment = DEFAULT_ALIGNMENT 
)
static

◆ MallocZeroedExternal()

void * FMemory::MallocZeroedExternal ( SIZE_T  Count,
uint32  Alignment = DEFAULT_ALIGNMENT 
)
static

◆ MarkTLSCachesAsUnusedOnCurrentThread()

void FMemory::MarkTLSCachesAsUnusedOnCurrentThread ( )
static

Mark TLS caches for current thread as unused. Typically before going to sleep. These are the threads that we can trim without waking them up.

◆ MarkTLSCachesAsUsedOnCurrentThread()

void FMemory::MarkTLSCachesAsUsedOnCurrentThread ( )
static

Mark TLS caches for the current thread as used. Thread has woken up to do some processing and needs its TLS caches back.

◆ Memcmp()

static UE_FORCEINLINE_HINT int32 FMemory::Memcmp ( const void Buf1,
const void Buf2,
SIZE_T  Count 
)
inlinestatic

◆ Memcpy() [1/2]

template<class T >
static void FMemory::Memcpy ( T &  Dest,
const T &  Src 
)
inlinestatic

◆ Memcpy() [2/2]

static UE_FORCEINLINE_HINT void * FMemory::Memcpy ( void Dest,
const void Src,
SIZE_T  Count 
)
inlinestatic

◆ MemIsZero()

static bool FMemory::MemIsZero ( const void Ptr,
SIZE_T  Count 
)
inlinestatic

Returns true if memory is zeroes, false otherwise.

◆ Memmove()

static UE_FORCEINLINE_HINT void * FMemory::Memmove ( void Dest,
const void Src,
SIZE_T  Count 
)
inlinestatic

◆ Memset() [1/2]

template<class T >
static void FMemory::Memset ( T &  Src,
uint8  ValueToSet 
)
inlinestatic

◆ Memset() [2/2]

static UE_FORCEINLINE_HINT void * FMemory::Memset ( void Dest,
uint8  Char,
SIZE_T  Count 
)
inlinestatic

◆ Memswap()

static UE_FORCEINLINE_HINT void FMemory::Memswap ( void Ptr1,
void Ptr2,
SIZE_T  Size 
)
inlinestatic

◆ Memzero() [1/2]

template<class T >
static void FMemory::Memzero ( T &  Src)
inlinestatic

◆ Memzero() [2/2]

static UE_FORCEINLINE_HINT void * FMemory::Memzero ( void Dest,
SIZE_T  Count 
)
inlinestatic

◆ ParallelMemcpy()

static UE_FORCEINLINE_HINT void * FMemory::ParallelMemcpy ( void Dest,
const void Src,
SIZE_T  Count,
EMemcpyCachePolicy  Policy = EMemcpyCachePolicy::StoreCached 
)
inlinestatic

◆ QuantizeSize()

SIZE_T FMemory::QuantizeSize ( SIZE_T  Count,
uint32  Alignment = DEFAULT_ALIGNMENT 
)
static

For some allocators this will return the actual size that should be requested to eliminate internal fragmentation. The return value will always be >= Count. This can be used to grow and shrink containers to optimal sizes. This call is always fast and threadsafe with no locking.

◆ QuantizeSizeExternal()

SIZE_T FMemory::QuantizeSizeExternal ( SIZE_T  Count,
uint32  Alignment = DEFAULT_ALIGNMENT 
)
static

◆ ReallocExternal()

void * FMemory::ReallocExternal ( void Original,
SIZE_T  Count,
uint32  Alignment = DEFAULT_ALIGNMENT 
)
static

◆ SetupTLSCachesOnCurrentThread()

void FMemory::SetupTLSCachesOnCurrentThread ( )
static

Set up TLS caches on the current thread. These are the threads that we can trim.

◆ StreamingMemcpy()

static UE_FORCEINLINE_HINT void * FMemory::StreamingMemcpy ( void Dest,
const void Src,
SIZE_T  Count 
)
inlinestatic

◆ SystemFree()

static void FMemory::SystemFree ( void Ptr)
inlinestatic

◆ TestMemory()

void FMemory::TestMemory ( )
static

A helper function that will perform a series of random heap allocations to test the internal validity of the heap. Note, this function will "leak" memory, but another call will clean up previously allocated blocks before returning. This will help to A/B testing where you call it in a good state, do something to corrupt memory, then call this again and hopefully freeing some pointers will trigger a crash.

◆ Trim()

void FMemory::Trim ( bool  bTrimThreadCaches = true)
static

Releases as much memory as possible. Must be called from the main thread.

◆ UE_ALLOCATION_FUNCTION() [1/4]

FMemory::UE_ALLOCATION_FUNCTION ( )
inline

◆ UE_ALLOCATION_FUNCTION() [2/4]

FMemory::UE_ALLOCATION_FUNCTION ( ,
 
)

◆ UE_ALLOCATION_FUNCTION() [3/4]

FMemory::UE_ALLOCATION_FUNCTION ( ,
 
)

◆ UE_ALLOCATION_FUNCTION() [4/4]

FMemory::UE_ALLOCATION_FUNCTION ( ,
 
)

Member Data Documentation

◆ Alignment [1/2]

uint32 FMemory::Alignment = DEFAULT_ALIGNMENT)

◆ Alignment [2/2]

SIZE_T uint32 FMemory::Alignment = DEFAULT_ALIGNMENT)

◆ Count

SIZE_T FMemory::Count

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