Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FMallocCallstackHandler Class Referenceabstract

#include <MallocCallstackHandler.h>

+ Inheritance diagram for FMallocCallstackHandler:
+ Collaboration diagram for FMallocCallstackHandler:

Classes

struct  FCallStackInfo
 
struct  FCallStackMapKey
 

Public Member Functions

 FMallocCallstackHandler (FMalloc *InMalloc)
 
virtual voidMalloc (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT) override
 
virtual voidRealloc (void *Original, SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT) override
 
virtual void Free (void *Original) override
 
virtual SIZE_T QuantizeSize (SIZE_T Count, uint32 Alignment) override
 
virtual bool GetAllocationSize (void *Original, SIZE_T &SizeOut) override
 
virtual void Trim (bool bTrimThreadCaches) override
 
virtual void SetupTLSCachesOnCurrentThread () override
 
virtual void ClearAndDisableTLSCachesOnCurrentThread () override
 
virtual void InitializeStatsMetadata () override
 
virtual void UpdateStats () override
 
virtual void GetAllocatorStats (FGenericMemoryStats &out_Stats) override
 
virtual void DumpAllocatorStats (class FOutputDevice &Ar) override
 
virtual bool IsInternallyThreadSafe () const override
 
virtual bool ValidateHeap () override
 
virtual const TCHAR * GetDescriptiveName () override
 
virtual void OnMallocInitialized () override
 
virtual void OnPreFork () override
 
virtual void OnPostFork () override
 
virtual void Init ()
 
void DumpStackTraceToLog (int32 StackIndex)
 
- Public Member Functions inherited from FMalloc
virtual voidTryMalloc (SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
virtual voidTryRealloc (void *Original, SIZE_T Count, uint32 Alignment=DEFAULT_ALIGNMENT)
 
- Public Member Functions inherited from FUseSystemMallocForNew
voidoperator new (size_t Size)
 
void operator delete (void *Ptr)
 
voidoperator new[] (size_t Size)
 
void operator delete[] (void *Ptr)
 
- Public Member Functions inherited from FExec
virtual ~FExec ()
 
virtual bool Exec (UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar)
 

Static Public Attributes

static constexpr SIZE_T MaxCallStackDepth = 64
 
static constexpr SIZE_T CallStackEntriesToSkipCount = 2
 
- Static Public Attributes inherited from FMalloc
static TAtomic< uint64MaxSingleAlloc
 

Protected Member Functions

FORCEINLINE void IncDisabled ()
 
FORCEINLINE void DecDisabled ()
 
virtual bool IsDisabled ()
 
virtual void TrackRealloc (void *OldPtr, void *NewPtr, uint32 NewSize, uint32 OldSize, int32 CallStackIndex)
 
virtual void TrackMalloc (void *Ptr, uint32 Size, int32 CallStackIndex)=0
 
virtual void TrackFree (void *Ptr, uint32 OldSize, int32 CallStackIndex)=0
 
virtual int32 GetCallStackIndex ()
 
- Protected Member Functions inherited from FExec
virtual bool Exec_Dev (UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar)
 
virtual bool Exec_Editor (UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar)
 

Protected Attributes

FMallocUsedMalloc
 
bool Initialized
 
FCriticalSection CriticalSection
 
uint32 DisabledTLS
 
FRWLock RWLock
 
TMap< FCallStackMapKey, int32CallStackMapKeyToCallStackIndexMap
 
TArray< FCallStackInfoCallStackInfoArray
 

Friends

class FScopeDisableMallocCallstackHandler
 

Detailed Description

Definition at line 15 of file MallocCallstackHandler.h.

Constructor & Destructor Documentation

◆ FMallocCallstackHandler()

FMallocCallstackHandler::FMallocCallstackHandler ( FMalloc * InMalloc)

Member Function Documentation

◆ ClearAndDisableTLSCachesOnCurrentThread()

virtual void FMallocCallstackHandler::ClearAndDisableTLSCachesOnCurrentThread ( )
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 77 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ DecDisabled()

FORCEINLINE void FMallocCallstackHandler::DecDisabled ( )
inlineprotected

Definition at line 217 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DumpAllocatorStats()

virtual void FMallocCallstackHandler::DumpAllocatorStats ( class FOutputDevice & Ar)
inlineoverridevirtual

Dumps current allocator stats to the log.

Reimplemented from FMalloc.

Definition at line 104 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ DumpStackTraceToLog()

void FMallocCallstackHandler::DumpStackTraceToLog ( int32 StackIndex)

◆ Free()

virtual void FMallocCallstackHandler::Free ( void * Original)
overridevirtual

Free

Implements FMalloc.

◆ GetAllocationSize()

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

Definition at line 53 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ GetAllocatorStats()

virtual void FMallocCallstackHandler::GetAllocatorStats ( FGenericMemoryStats & out_Stats)
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 98 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ GetCallStackIndex()

virtual int32 FMallocCallstackHandler::GetCallStackIndex ( )
protectedvirtual

◆ GetDescriptiveName()

virtual const TCHAR * FMallocCallstackHandler::GetDescriptiveName ( )
inlineoverridevirtual

Gets descriptive name for logging purposes.

Returns
pointer to human-readable malloc name

Reimplemented from FMalloc.

Definition at line 131 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ IncDisabled()

FORCEINLINE void FMallocCallstackHandler::IncDisabled ( )
inlineprotected

Definition at line 210 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Init()

virtual void FMallocCallstackHandler::Init ( )
virtual

◆ InitializeStatsMetadata()

virtual void FMallocCallstackHandler::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.

Definition at line 86 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ IsDisabled()

virtual bool FMallocCallstackHandler::IsDisabled ( )
inlineprotectedvirtual

Reimplemented in FMallocFrameProfiler.

Definition at line 223 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ IsInternallyThreadSafe()

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

Definition at line 113 of file MallocCallstackHandler.h.

◆ Malloc()

virtual void * FMallocCallstackHandler::Malloc ( SIZE_T Count,
uint32 Alignment = DEFAULT_ALIGNMENT )
overridevirtual

Malloc

Implements FMalloc.

◆ OnMallocInitialized()

virtual void FMallocCallstackHandler::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.

Definition at line 136 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ OnPostFork()

virtual void FMallocCallstackHandler::OnPostFork ( )
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 146 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ OnPreFork()

virtual void FMallocCallstackHandler::OnPreFork ( )
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 141 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ QuantizeSize()

virtual SIZE_T FMallocCallstackHandler::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 thread safe with no locking.

Reimplemented from FMalloc.

Definition at line 41 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ Realloc()

virtual void * FMallocCallstackHandler::Realloc ( void * Original,
SIZE_T Count,
uint32 Alignment = DEFAULT_ALIGNMENT )
overridevirtual

Realloc

Implements FMalloc.

◆ SetupTLSCachesOnCurrentThread()

virtual void FMallocCallstackHandler::SetupTLSCachesOnCurrentThread ( )
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 69 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ TrackFree()

virtual void FMallocCallstackHandler::TrackFree ( void * Ptr,
uint32 OldSize,
int32 CallStackIndex )
protectedpure virtual

◆ TrackMalloc()

virtual void FMallocCallstackHandler::TrackMalloc ( void * Ptr,
uint32 Size,
int32 CallStackIndex )
protectedpure virtual

◆ TrackRealloc()

virtual void FMallocCallstackHandler::TrackRealloc ( void * OldPtr,
void * NewPtr,
uint32 NewSize,
uint32 OldSize,
int32 CallStackIndex )
protectedvirtual

Reimplemented in FMallocFrameProfiler.

◆ Trim()

virtual void FMallocCallstackHandler::Trim ( bool bTrimThreadCaches)
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 61 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ UpdateStats()

virtual void FMallocCallstackHandler::UpdateStats ( )
inlineoverridevirtual

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

Reimplemented from FMalloc.

Reimplemented in FMallocFrameProfiler.

Definition at line 92 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

◆ ValidateHeap()

virtual bool FMallocCallstackHandler::ValidateHeap ( )
inlineoverridevirtual

Validates the allocator's heap

Reimplemented from FMalloc.

Definition at line 121 of file MallocCallstackHandler.h.

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ FScopeDisableMallocCallstackHandler

Member Data Documentation

◆ CallStackEntriesToSkipCount

constexpr SIZE_T FMallocCallstackHandler::CallStackEntriesToSkipCount = 2
staticconstexpr

Definition at line 152 of file MallocCallstackHandler.h.

◆ CallStackInfoArray

TArray<FCallStackInfo> FMallocCallstackHandler::CallStackInfoArray
protected

Definition at line 235 of file MallocCallstackHandler.h.

◆ CallStackMapKeyToCallStackIndexMap

TMap<FCallStackMapKey, int32> FMallocCallstackHandler::CallStackMapKeyToCallStackIndexMap
protected

Definition at line 234 of file MallocCallstackHandler.h.

◆ CriticalSection

FCriticalSection FMallocCallstackHandler::CriticalSection
protected

Definition at line 207 of file MallocCallstackHandler.h.

◆ DisabledTLS

uint32 FMallocCallstackHandler::DisabledTLS
protected

Definition at line 208 of file MallocCallstackHandler.h.

◆ Initialized

bool FMallocCallstackHandler::Initialized
protected

Definition at line 206 of file MallocCallstackHandler.h.

◆ MaxCallStackDepth

constexpr SIZE_T FMallocCallstackHandler::MaxCallStackDepth = 64
staticconstexpr

Definition at line 151 of file MallocCallstackHandler.h.

◆ RWLock

FRWLock FMallocCallstackHandler::RWLock
protected

Definition at line 232 of file MallocCallstackHandler.h.

◆ UsedMalloc

FMalloc* FMallocCallstackHandler::UsedMalloc
protected

Malloc we're based on, aka using under the hood

Definition at line 205 of file MallocCallstackHandler.h.


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