UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FMallocBinned2 Class Reference

#include <MallocBinned2.h>

+ Inheritance diagram for FMallocBinned2:

Classes

struct  FPoolInfo
 
struct  FPoolTable
 
struct  Private
 

Public Member Functions

 FMallocBinned2 ()
 
virtual ~FMallocBinned2 ()
 
virtual bool IsInternallyThreadSafe () const override
 
virtual UE_AUTORTFM_NOAUTORTFM voidMalloc (SIZE_T Size, uint32 Alignment) override
 
virtual UE_AUTORTFM_NOAUTORTFM voidRealloc (void *Ptr, SIZE_T NewSize, uint32 Alignment) override
 
virtual UE_AUTORTFM_NOAUTORTFM void Free (void *Ptr) override
 
bool GetSmallAllocationSize (void *Ptr, SIZE_T &SizeOut) const
 
virtual bool GetAllocationSize (void *Ptr, SIZE_T &SizeOut) override
 
virtual FORCEINLINE SIZE_T QuantizeSize (SIZE_T Count, uint32 Alignment) override
 
virtual bool ValidateHeap () override
 
virtual void Trim (bool bTrimThreadCaches) override
 
virtual const TCHARGetDescriptiveName () override
 
virtual void UpdateStats () override
 
virtual void OnMallocInitialized () override
 
virtual void OnPreFork () override
 
virtual void OnPostFork () override
 
virtual uint64 GetImmediatelyFreeableCachedMemorySize () const override
 
virtual uint64 GetTotalFreeCachedMemorySize () const override
 
voidMallocExternalSmall (SIZE_T Size, uint32 Alignment)
 
voidMallocExternalLarge (SIZE_T Size, uint32 Alignment)
 
void CanaryFail (const FFreeBlock *Block) const
 
void CanaryTest (const FFreeBlock *Block) const
 
virtual void DumpAllocatorStats (class FOutputDevice &Ar) override
 
FORCEINLINE uint32 PoolIndexToBinSize (uint32 PoolIndex) const
 
void FreeBundles (FBundleNode *Bundles, uint32 PoolIndex)
 
void FlushCurrentThreadCacheInternal (bool bNewEpochOnly=false)
 
- Public Member Functions inherited from TMallocBinnedCommon< FMallocBinned2, UE_MB2_SMALL_POOL_COUNT, UE_MB2_MAX_SMALL_POOL_SIZE >
virtual void GetAllocatorStats (FGenericMemoryStats &OutStats) override
 
- Public Member Functions inherited from FMalloc
virtual CORE_API voidTryMalloc (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
virtual CORE_API voidTryRealloc (void *Original, SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
virtual CORE_API voidMallocZeroed (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
virtual CORE_API voidTryMallocZeroed (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
virtual CORE_API void InitializeStatsMetadata ()
 
- 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 Member Functions

static voidAllocateMetaDataMemory (SIZE_T Size)
 
static void FreeMetaDataMemory (void *Ptr, SIZE_T Size)
 

Public Attributes

FPoolTable SmallPoolTables [UE_MB2_SMALL_POOL_COUNT]
 

Static Public Attributes

static uint16 SmallBinSizes [UE_MB2_SMALL_POOL_COUNT] = { 0 }
 
static FMallocBinned2MallocBinned2 = nullptr
 
static uint8 MemSizeToPoolIndex [1+(UE_MB2_MAX_SMALL_POOL_SIZE > > UE_MBC_BIN_SIZE_SHIFT)] = { 0 }
 
- Static Public Attributes inherited from FMalloc
static CORE_API TAtomic< uint64MaxSingleAlloc
 

Additional Inherited Members

- Protected Member Functions inherited from TMallocBinnedCommon< FMallocBinned2, UE_MB2_SMALL_POOL_COUNT, UE_MB2_MAX_SMALL_POOL_SIZE >
virtual void SetupTLSCachesOnCurrentThread () override
 
virtual void ClearAndDisableTLSCachesOnCurrentThread () override
 
virtual void MarkTLSCachesAsUsedOnCurrentThread () override
 
virtual void MarkTLSCachesAsUnusedOnCurrentThread () override
 
SIZE_T QuantizeSizeCommon (SIZE_T Count, uint32 Alignment, const FMallocBinned2 &Alloc) const
 
uint32 BoundSizeToPoolIndex (SIZE_T Size, const uint8(&MemSizeToPoolIndex)[SIZE_TO_POOL_INDEX_NUM]) const
 
FORCENOINLINE bool PromoteToLargerBin (SIZE_T &Size, uint32 &Alignment, const FMallocBinned2 &Alloc) const
 
bool GetAllocationSizeExternal (void *Ptr, SIZE_T &SizeOut)
 
int64 GetTotalAllocatedSmallPoolMemory () const
 
void UpdateStatsCommon (const FMallocBinned2 &Alloc)
 
void AllocateHashBuckets ()
 
- Protected Member Functions inherited from FMallocBinnedCommonBase
void GetAllocatorStatsInternal (FGenericMemoryStats &OutStats, int64 TotalAllocatedSmallPoolMemory)
 
void UnrecognizedPointerFatalError (void *Ptr)
 
void LogLargeAllocation (SIZE_T Size) const
 
- 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)
 
- Static Protected Member Functions inherited from TMallocBinnedCommon< FMallocBinned2, UE_MB2_SMALL_POOL_COUNT, UE_MB2_MAX_SMALL_POOL_SIZE >
static UE::FPlatformRecursiveMutexGetFreeBlockListsRegistrationMutex ()
 
static TArray< FPerThreadFreeBlockLists * > & GetRegisteredFreeBlockLists ()
 
- Static Protected Member Functions inherited from FMallocBinnedCommonBase
static void OutOfMemory (uint64 Size, uint32 Alignment=0)
 
- Protected Attributes inherited from FMallocBinnedCommonBase
FPtrToPoolMapping PtrToPoolMapping
 
uint64 NumPoolsPerPage
 
UE::FPlatformRecursiveMutex ExternalAllocMutex
 
std::atomic< uint64MemoryTrimEpoch { 0 }
 
- Static Protected Attributes inherited from TMallocBinnedCommon< FMallocBinned2, UE_MB2_SMALL_POOL_COUNT, UE_MB2_MAX_SMALL_POOL_SIZE >
static constexpr int SIZE_TO_POOL_INDEX_NUM
 
- Static Protected Attributes inherited from FMallocBinnedCommonBase
static uint32 OsAllocationGranularity = 0
 
static CORE_API uint32 BinnedTlsSlot = FPlatformTLS::InvalidTlsSlot
 
static std::atomic< int64TLSMemory
 
static std::atomic< int64ConsolidatedMemory
 
static std::atomic< int64AllocatedSmallPoolMemory
 
static std::atomic< int64AllocatedOSSmallPoolMemory
 
static std::atomic< int64AllocatedLargePoolMemory
 
static std::atomic< int64AllocatedLargePoolMemoryWAlignment
 
static int64 PoolInfoMemory
 
static int64 HashMemory
 

Constructor & Destructor Documentation

◆ FMallocBinned2()

FMallocBinned2::FMallocBinned2 ( )

◆ ~FMallocBinned2()

FMallocBinned2::~FMallocBinned2 ( )
virtual

Member Function Documentation

◆ AllocateMetaDataMemory()

void * FMallocBinned2::AllocateMetaDataMemory ( SIZE_T  Size)
static

◆ CanaryFail()

void FMallocBinned2::CanaryFail ( const FFreeBlock *  Block) const

◆ CanaryTest()

void FMallocBinned2::CanaryTest ( const FFreeBlock *  Block) const
inline

◆ DumpAllocatorStats()

void FMallocBinned2::DumpAllocatorStats ( class FOutputDevice Ar)
overridevirtual

Dumps current allocator stats to the log.

Reimplemented from FMalloc.

◆ FlushCurrentThreadCacheInternal()

void FMallocBinned2::FlushCurrentThreadCacheInternal ( bool  bNewEpochOnly = false)

◆ Free()

void FMallocBinned2::Free ( void Original)
overridevirtual

Free

Implements FMalloc.

◆ FreeBundles()

void FMallocBinned2::FreeBundles ( FBundleNode Bundles,
uint32  PoolIndex 
)

◆ FreeMetaDataMemory()

void FMallocBinned2::FreeMetaDataMemory ( void Ptr,
SIZE_T  Size 
)
static

◆ GetAllocationSize()

virtual bool FMallocBinned2::GetAllocationSize ( void Original,
SIZE_T SizeOut 
)
inlineoverridevirtual

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 from FMalloc.

◆ GetDescriptiveName()

const TCHAR * FMallocBinned2::GetDescriptiveName ( )
overridevirtual

Gets descriptive name for logging purposes.

Returns
pointer to human-readable malloc name

Reimplemented from FMalloc.

◆ GetImmediatelyFreeableCachedMemorySize()

virtual uint64 FMallocBinned2::GetImmediatelyFreeableCachedMemorySize ( ) const
inlineoverridevirtual

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

Reimplemented from FMalloc.

◆ GetSmallAllocationSize()

bool FMallocBinned2::GetSmallAllocationSize ( void Ptr,
SIZE_T SizeOut 
) const
inline

◆ GetTotalFreeCachedMemorySize()

virtual uint64 FMallocBinned2::GetTotalFreeCachedMemorySize ( ) const
inlineoverridevirtual

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 from FMalloc.

◆ IsInternallyThreadSafe()

bool FMallocBinned2::IsInternallyThreadSafe ( ) const
overridevirtual

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

Reimplemented from FMalloc.

◆ Malloc()

void * FMallocBinned2::Malloc ( SIZE_T  Count,
uint32  Alignment 
)
overridevirtual

Malloc

Implements FMalloc.

◆ MallocExternalLarge()

void * FMallocBinned2::MallocExternalLarge ( SIZE_T  Size,
uint32  Alignment 
)

◆ MallocExternalSmall()

void * FMallocBinned2::MallocExternalSmall ( SIZE_T  Size,
uint32  Alignment 
)

◆ OnMallocInitialized()

void FMallocBinned2::OnMallocInitialized ( )
overridevirtual

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 from FMallocBinnedCommonBase.

◆ OnPostFork()

void FMallocBinned2::OnPostFork ( )
overridevirtual

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

Reimplemented from FMalloc.

◆ OnPreFork()

void FMallocBinned2::OnPreFork ( )
overridevirtual

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

Reimplemented from FMalloc.

◆ PoolIndexToBinSize()

FORCEINLINE uint32 FMallocBinned2::PoolIndexToBinSize ( uint32  PoolIndex) const
inline

◆ QuantizeSize()

virtual FORCEINLINE SIZE_T FMallocBinned2::QuantizeSize ( SIZE_T  Count,
uint32  Alignment 
)
inlineoverridevirtual

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 from FMalloc.

◆ Realloc()

void * FMallocBinned2::Realloc ( void Original,
SIZE_T  Count,
uint32  Alignment 
)
overridevirtual

Realloc

Implements FMalloc.

◆ Trim()

void FMallocBinned2::Trim ( bool  bTrimThreadCaches)
overridevirtual

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

Reimplemented from FMalloc.

◆ UpdateStats()

void FMallocBinned2::UpdateStats ( )
overridevirtual

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

Reimplemented from FMalloc.

◆ ValidateHeap()

bool FMallocBinned2::ValidateHeap ( )
overridevirtual

Validates the allocator's heap

Reimplemented from FMalloc.

Member Data Documentation

◆ MallocBinned2

FMallocBinned2 * FMallocBinned2::MallocBinned2 = nullptr
static

◆ MemSizeToPoolIndex

uint8 FMallocBinned2::MemSizeToPoolIndex = { 0 }
static

◆ SmallBinSizes

uint16 FMallocBinned2::SmallBinSizes = { 0 }
static

◆ SmallPoolTables

FPoolTable FMallocBinned2::SmallPoolTables[UE_MB2_SMALL_POOL_COUNT]

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