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

#include <MallocThreadSafeProxy.h>

+ Inheritance diagram for FMallocThreadSafeProxy:

Public Member Functions

 FMallocThreadSafeProxy (FMalloc *InMalloc)
 
virtual void InitializeStatsMetadata () override
 
virtual voidMalloc (SIZE_T Size, uint32 Alignment) override
 
virtual voidRealloc (void *Ptr, SIZE_T NewSize, uint32 Alignment) override
 
virtual void Free (void *Ptr) override
 
virtual void GetAllocatorStats (FGenericMemoryStats &out_Stats) override
 
virtual void DumpAllocatorStats (class FOutputDevice &Ar) override
 
virtual bool ValidateHeap () override
 
virtual bool GetAllocationSize (void *Original, SIZE_T &SizeOut) override
 
virtual const TCHARGetDescriptiveName () override
 
virtual void Trim (bool bTrimThreadCaches) override
 
virtual bool IsInternallyThreadSafe () const override
 
virtual void OnMallocInitialized () override
 
virtual void OnPreFork () override
 
virtual void OnPostFork () 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 SIZE_T QuantizeSize (SIZE_T Count, uint32 Alignment)
 
virtual void SetupTLSCachesOnCurrentThread ()
 
virtual void MarkTLSCachesAsUsedOnCurrentThread ()
 
virtual void MarkTLSCachesAsUnusedOnCurrentThread ()
 
virtual void ClearAndDisableTLSCachesOnCurrentThread ()
 
virtual CORE_API void UpdateStats ()
 
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)
 

Additional Inherited Members

- Static Public Attributes inherited from FMalloc
static CORE_API TAtomic< uint64MaxSingleAlloc
 
- 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

FMalloc proxy that synchronizes access, making the used malloc thread safe.

Constructor & Destructor Documentation

◆ FMallocThreadSafeProxy()

FMallocThreadSafeProxy::FMallocThreadSafeProxy ( FMalloc InMalloc)
inline

Constructor for thread safe proxy malloc that takes a malloc to be used and a synchronization object used via FScopeLock as a parameter.

Parameters
InMallocFMalloc that is going to be used for actual allocations

Member Function Documentation

◆ DumpAllocatorStats()

virtual void FMallocThreadSafeProxy::DumpAllocatorStats ( class FOutputDevice Ar)
inlineoverridevirtual

Dumps allocator stats to an output device.

Reimplemented from FMalloc.

◆ Free()

virtual void FMallocThreadSafeProxy::Free ( void Ptr)
inlineoverridevirtual

Free

Implements FMalloc.

◆ GetAllocationSize()

virtual bool FMallocThreadSafeProxy::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.

◆ GetAllocatorStats()

virtual void FMallocThreadSafeProxy::GetAllocatorStats ( FGenericMemoryStats out_Stats)
inlineoverridevirtual

Writes allocator stats from the last update into the specified destination.

Reimplemented from FMalloc.

◆ GetDescriptiveName()

virtual const TCHAR * FMallocThreadSafeProxy::GetDescriptiveName ( )
inlineoverridevirtual

Gets descriptive name for logging purposes.

Returns
pointer to human-readable malloc name

Reimplemented from FMalloc.

◆ InitializeStatsMetadata()

virtual void FMallocThreadSafeProxy::InitializeStatsMetadata ( )
inlineoverridevirtual

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

◆ IsInternallyThreadSafe()

virtual bool FMallocThreadSafeProxy::IsInternallyThreadSafe ( ) const
inlineoverridevirtual

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()

virtual void * FMallocThreadSafeProxy::Malloc ( SIZE_T  Size,
uint32  Alignment 
)
inlineoverridevirtual

Malloc

Implements FMalloc.

◆ OnMallocInitialized()

virtual void FMallocThreadSafeProxy::OnMallocInitialized ( )
inlineoverridevirtual

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

◆ OnPostFork()

virtual void FMallocThreadSafeProxy::OnPostFork ( )
inlineoverridevirtual

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

Reimplemented from FMalloc.

◆ OnPreFork()

virtual void FMallocThreadSafeProxy::OnPreFork ( )
inlineoverridevirtual

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

Reimplemented from FMalloc.

◆ Realloc()

virtual void * FMallocThreadSafeProxy::Realloc ( void Ptr,
SIZE_T  NewSize,
uint32  Alignment 
)
inlineoverridevirtual

Realloc

Implements FMalloc.

◆ Trim()

virtual void FMallocThreadSafeProxy::Trim ( bool  bTrimThreadCaches)
inlineoverridevirtual

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

Reimplemented from FMalloc.

◆ ValidateHeap()

virtual bool FMallocThreadSafeProxy::ValidateHeap ( )
inlineoverridevirtual

Validates the allocator's heap

Reimplemented from FMalloc.


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