UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FMalloc Class Referenceabstract

#include <MemoryBase.h>

+ Inheritance diagram for FMalloc:

Public Member Functions

virtual voidMalloc (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)=0
 
virtual CORE_API voidTryMalloc (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
virtual voidRealloc (void *Original, SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)=0
 
virtual CORE_API voidTryRealloc (void *Original, SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
virtual void Free (void *Original)=0
 
virtual CORE_API voidMallocZeroed (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
virtual CORE_API voidTryMallocZeroed (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
virtual SIZE_T QuantizeSize (SIZE_T Count, uint32 Alignment)
 
virtual bool GetAllocationSize (void *Original, SIZE_T &SizeOut)
 
virtual void Trim (bool bTrimThreadCaches)
 
virtual void SetupTLSCachesOnCurrentThread ()
 
virtual void MarkTLSCachesAsUsedOnCurrentThread ()
 
virtual void MarkTLSCachesAsUnusedOnCurrentThread ()
 
virtual void ClearAndDisableTLSCachesOnCurrentThread ()
 
virtual CORE_API void InitializeStatsMetadata ()
 
virtual CORE_API void UpdateStats ()
 
virtual CORE_API void GetAllocatorStats (FGenericMemoryStats &out_Stats)
 
virtual void DumpAllocatorStats (class FOutputDevice &Ar)
 
virtual bool IsInternallyThreadSafe () const
 
virtual bool ValidateHeap ()
 
virtual const TCHARGetDescriptiveName ()
 
virtual void OnMallocInitialized ()
 
virtual void OnPreFork ()
 
virtual void OnPostFork ()
 
virtual uint64 GetImmediatelyFreeableCachedMemorySize () const
 
virtual uint64 GetTotalFreeCachedMemorySize () const
 
- Public Member Functions inherited from FUseSystemMallocForNew
CORE_API voidoperator new (size_t Size)
 
CORE_API void operator delete (void *Ptr)
 
voidoperator new[] (size_t Size)
 
void operator delete[] (void *Ptr)
 
- Public Member Functions inherited from FExec
virtual CORE_API ~FExec ()
 
virtual CORE_API bool Exec (UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar)
 

Static Public Attributes

static CORE_API TAtomic< uint64MaxSingleAlloc
 

Friends

struct FCurrentFrameCalls
 

Additional Inherited Members

- Protected Member Functions inherited from FExec
virtual bool Exec_Runtime (UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar)
 
virtual bool Exec_Dev (UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar)
 
virtual bool Exec_Editor (UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar)
 

Detailed Description

The global memory allocator's interface.

Member Function Documentation

◆ ClearAndDisableTLSCachesOnCurrentThread()

virtual void FMalloc::ClearAndDisableTLSCachesOnCurrentThread ( )
inlinevirtual

◆ DumpAllocatorStats()

virtual void FMalloc::DumpAllocatorStats ( class FOutputDevice Ar)
inlinevirtual

◆ Free()

◆ GetAllocationSize()

virtual bool FMalloc::GetAllocationSize ( void Original,
SIZE_T SizeOut 
)
inlinevirtual

If possible determine the size of the memory allocated at the given address

Parameters
Original- Pointer to memory we are checking the size of
SizeOut- If possible, this value is set to the size of the passed in pointer
Returns
true if succeeded

Reimplemented in FMallocPurgatoryProxy, FGenericPlatformMallocCrash, FMallocAnsi, FMallocBinned, FMallocCallstackHandler, FMallocDebug, FMallocPoisonProxy, FMallocThreadSafeProxy, FIOSMallocZone, FIOSMallocCrashHandler, FMacMallocZone, FMacMallocCrashHandler, and FMallocBinned2.

◆ GetAllocatorStats()

◆ GetDescriptiveName()

virtual const TCHAR * FMalloc::GetDescriptiveName ( )
inlinevirtual

◆ GetImmediatelyFreeableCachedMemorySize()

virtual uint64 FMalloc::GetImmediatelyFreeableCachedMemorySize ( ) const
inlinevirtual

Returns the amount of free memory cached by the allocator that can be returned to the system in case of a memory shortage

Reimplemented in FMallocBinned2.

◆ GetTotalFreeCachedMemorySize()

virtual uint64 FMalloc::GetTotalFreeCachedMemorySize ( ) const
inlinevirtual

Returns the amount of total free memory cached by the allocator. This includes memory that can be returned to the system in case of a memory shortage, see GetImmediatelyFreeableCachedMemorySize() as well as any memory that can't be returned back to the kernel, but can be used to satisfy some of the allocation requirements.

Reimplemented in FMallocBinned2.

◆ InitializeStatsMetadata()

void FMalloc::InitializeStatsMetadata ( )
virtual

Initializes stats metadata. We need to do this as soon as possible, but cannot be done in the constructor due to the FName::StaticInit

Reimplemented in FMallocPurgatoryProxy, FMallocBinned, FMallocCallstackHandler, FMallocPoisonProxy, and FMallocThreadSafeProxy.

◆ IsInternallyThreadSafe()

virtual bool FMalloc::IsInternallyThreadSafe ( ) const
inlinevirtual

Returns if the allocator is guaranteed to be thread-safe and therefore doesn't need a unnecessary thread-safety wrapper around it.

Reimplemented in FGenericPlatformMallocCrash, FMallocAnsi, FMallocBinned, FMallocBinned2, FMallocCallstackHandler, FMallocPoisonProxy, FMallocThreadSafeProxy, FIOSMallocZone, and FMacMallocZone.

◆ Malloc()

◆ MallocZeroed()

void * FMalloc::MallocZeroed ( SIZE_T  Count,
uint32  Alignment = DEFAULT_ALIGNMENT 
)
virtual

Malloc zeroed memory

Reimplemented in FMallocPoisonProxy.

◆ MarkTLSCachesAsUnusedOnCurrentThread()

virtual void FMalloc::MarkTLSCachesAsUnusedOnCurrentThread ( )
inlinevirtual

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.

Reimplemented in FMallocCallstackHandler, FMallocPurgatoryProxy, TMallocBinnedCommon< AllocType, NumSmallPools, MaxSmallPoolSize >, TMallocBinnedCommon< FMallocBinned2, UE_MB2_SMALL_POOL_COUNT, UE_MB2_MAX_SMALL_POOL_SIZE >, and FMallocPoisonProxy.

◆ MarkTLSCachesAsUsedOnCurrentThread()

virtual void FMalloc::MarkTLSCachesAsUsedOnCurrentThread ( )
inlinevirtual

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

Reimplemented in FMallocPurgatoryProxy, TMallocBinnedCommon< AllocType, NumSmallPools, MaxSmallPoolSize >, TMallocBinnedCommon< FMallocBinned2, UE_MB2_SMALL_POOL_COUNT, UE_MB2_MAX_SMALL_POOL_SIZE >, FMallocCallstackHandler, and FMallocPoisonProxy.

◆ OnMallocInitialized()

virtual void FMalloc::OnMallocInitialized ( )
inlinevirtual

Notifies the malloc implementation that initialization of all allocators in GMalloc is complete, so it's safe to initialize any extra features that require "regular" allocations

Reimplemented in FMallocPurgatoryProxy, FMallocBinned2, FMallocBinnedCommonBase, FMallocCallstackHandler, FMallocPoisonProxy, FMallocThreadSafeProxy, and FTraceMalloc.

◆ OnPostFork()

virtual void FMalloc::OnPostFork ( )
inlinevirtual

Notifies the malloc implementation that the process has forked so we can try and avoid dirtying pre-fork pages.

Reimplemented in FMallocPurgatoryProxy, FMallocBinned2, FMallocCallstackHandler, FMallocPoisonProxy, FMallocThreadSafeProxy, and FTraceMalloc.

◆ OnPreFork()

virtual void FMalloc::OnPreFork ( )
inlinevirtual

Notifies the malloc implementation that the process is about to fork. May be used to trim caches etc.

Reimplemented in FMallocPurgatoryProxy, FMallocBinned2, FMallocCallstackHandler, FMallocPoisonProxy, FMallocThreadSafeProxy, and FTraceMalloc.

◆ QuantizeSize()

virtual SIZE_T FMalloc::QuantizeSize ( SIZE_T  Count,
uint32  Alignment 
)
inlinevirtual

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.

Reimplemented in FMallocPurgatoryProxy, FMallocBinned, FMallocBinned2, FMallocCallstackHandler, and FMallocPoisonProxy.

◆ Realloc()

◆ SetupTLSCachesOnCurrentThread()

virtual void FMalloc::SetupTLSCachesOnCurrentThread ( )
inlinevirtual

◆ Trim()

virtual void FMalloc::Trim ( bool  bTrimThreadCaches)
inlinevirtual

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

Reimplemented in FMallocPurgatoryProxy, FMallocBinned2, FMallocCallstackHandler, FMallocPoisonProxy, and FMallocThreadSafeProxy.

◆ TryMalloc()

void * FMalloc::TryMalloc ( SIZE_T  Count,
uint32  Alignment = DEFAULT_ALIGNMENT 
)
virtual

TryMalloc - like Malloc(), but may return a nullptr result if the allocation request cannot be satisfied.

Reimplemented in FMallocAnsi.

◆ TryMallocZeroed()

void * FMalloc::TryMallocZeroed ( SIZE_T  Count,
uint32  Alignment = DEFAULT_ALIGNMENT 
)
virtual

TryMalloc - like MallocZeroed(), but may return a nullptr result if the allocation request cannot be satisfied.

◆ TryRealloc()

void * FMalloc::TryRealloc ( void Original,
SIZE_T  Count,
uint32  Alignment = DEFAULT_ALIGNMENT 
)
virtual

TryRealloc - like Realloc(), but may return a nullptr if the allocation request cannot be satisfied. Note that in this case the memory pointed to by Original will still be valid

Reimplemented in FMallocAnsi.

◆ UpdateStats()

void FMalloc::UpdateStats ( )
virtual

Called once per frame, gathers and sets all memory allocator statistics into the corresponding stats. MUST BE THREAD SAFE.

Reimplemented in FMallocBinned, FMallocBinned2, FMallocCallstackHandler, FMallocFrameProfiler, and FMallocPoisonProxy.

◆ ValidateHeap()

Friends And Related Symbol Documentation

◆ FCurrentFrameCalls

Member Data Documentation

◆ MaxSingleAlloc

TAtomic< uint64 > FMalloc::MaxSingleAlloc
static

Limits the maximum single allocation, to this many bytes, for debugging


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