Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FMallocPoisonProxy Class Reference

#include <MallocPoisonProxy.h>

+ Inheritance diagram for FMallocPoisonProxy:
+ Collaboration diagram for FMallocPoisonProxy:

Public Member Functions

 FMallocPoisonProxy (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 SIZE_T QuantizeSize (SIZE_T Count, uint32 Alignment) 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 bool Exec (UWorld *InWorld, const TCHAR *Cmd, FOutputDevice &Ar) override
 
virtual bool GetAllocationSize (void *Original, SIZE_T &SizeOut) override
 
virtual const TCHAR * GetDescriptiveName () override
 
virtual void Trim (bool bTrimThreadCaches) override
 
virtual void SetupTLSCachesOnCurrentThread () override
 
virtual void ClearAndDisableTLSCachesOnCurrentThread () override
 
virtual void OnMallocInitialized () override
 
virtual void OnPreFork () override
 
virtual void OnPostFork () override
 
- 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 ()
 

Private Attributes

FMallocUsedMalloc
 

Additional Inherited Members

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

Detailed Description

FMalloc proxy that poisons new and freed allocations, helping to catch code that relies on uninitialized or freed memory.

Definition at line 24 of file MallocPoisonProxy.h.

Constructor & Destructor Documentation

◆ FMallocPoisonProxy()

FMallocPoisonProxy::FMallocPoisonProxy ( FMalloc * InMalloc)
inlineexplicit

Definition at line 32 of file MallocPoisonProxy.h.

Member Function Documentation

◆ ClearAndDisableTLSCachesOnCurrentThread()

virtual void FMallocPoisonProxy::ClearAndDisableTLSCachesOnCurrentThread ( )
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 142 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ DumpAllocatorStats()

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

Dumps current allocator stats to the log.

Reimplemented from FMalloc.

Definition at line 102 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ Exec()

virtual bool FMallocPoisonProxy::Exec ( UWorld * InWorld,
const TCHAR * Cmd,
FOutputDevice & Ar )
inlineoverridevirtual

Exec handler

Parameters
InWorldWorld context
CmdCommand to parse
ArOutput device to log to
Returns
true if command was handled, false otherwise

Reimplemented from FExec.

Definition at line 117 of file MallocPoisonProxy.h.

◆ Free()

virtual void FMallocPoisonProxy::Free ( void * Original)
inlineoverridevirtual

Free

Implements FMalloc.

Definition at line 74 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ GetAllocationSize()

virtual bool FMallocPoisonProxy::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 122 of file MallocPoisonProxy.h.

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

◆ GetAllocatorStats()

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

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

Reimplemented from FMalloc.

Definition at line 97 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ GetDescriptiveName()

virtual const TCHAR * FMallocPoisonProxy::GetDescriptiveName ( )
inlineoverridevirtual

Gets descriptive name for logging purposes.

Returns
pointer to human-readable malloc name

Reimplemented from FMalloc.

Definition at line 127 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ InitializeStatsMetadata()

virtual void FMallocPoisonProxy::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 38 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ IsInternallyThreadSafe()

virtual bool FMallocPoisonProxy::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 107 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ Malloc()

virtual void * FMallocPoisonProxy::Malloc ( SIZE_T Count,
uint32 Alignment )
inlineoverridevirtual

Malloc

Implements FMalloc.

Definition at line 43 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ OnMallocInitialized()

virtual void FMallocPoisonProxy::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 147 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ OnPostFork()

virtual void FMallocPoisonProxy::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 158 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ OnPreFork()

virtual void FMallocPoisonProxy::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 152 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ QuantizeSize()

virtual SIZE_T FMallocPoisonProxy::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.

Definition at line 87 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ Realloc()

virtual void * FMallocPoisonProxy::Realloc ( void * Original,
SIZE_T Count,
uint32 Alignment )
inlineoverridevirtual

Realloc

Implements FMalloc.

Definition at line 53 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ SetupTLSCachesOnCurrentThread()

virtual void FMallocPoisonProxy::SetupTLSCachesOnCurrentThread ( )
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 137 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ Trim()

virtual void FMallocPoisonProxy::Trim ( bool bTrimThreadCaches)
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 132 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ UpdateStats()

virtual void FMallocPoisonProxy::UpdateStats ( )
inlineoverridevirtual

Handles any commands passed in on the command line This was commented out to make initial build -wooly Called once per frame, gathers and sets all memory allocator statistics into the corresponding stats. MUST BE THREAD SAFE.

Reimplemented from FMalloc.

Definition at line 92 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

◆ ValidateHeap()

virtual bool FMallocPoisonProxy::ValidateHeap ( )
inlineoverridevirtual

Validates the allocator's heap

Reimplemented from FMalloc.

Definition at line 112 of file MallocPoisonProxy.h.

+ Here is the call graph for this function:

Member Data Documentation

◆ UsedMalloc

FMalloc* FMallocPoisonProxy::UsedMalloc
private

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

Definition at line 28 of file MallocPoisonProxy.h.


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