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

#include <MallocThreadSafeProxy.h>

+ Inheritance diagram for FMallocThreadSafeProxy:
+ Collaboration 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 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 bool IsInternallyThreadSafe () const 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)
 
virtual SIZE_T QuantizeSize (SIZE_T Count, uint32 Alignment)
 
virtual void SetupTLSCachesOnCurrentThread ()
 
virtual void ClearAndDisableTLSCachesOnCurrentThread ()
 
virtual void UpdateStats ()
 
- 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
 
FCriticalSection SynchronizationObject
 

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 synchronizes access, making the used malloc thread safe.

Definition at line 13 of file MallocThreadSafeProxy.h.

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

Definition at line 28 of file MallocThreadSafeProxy.h.

Member Function Documentation

◆ DumpAllocatorStats()

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

Dumps allocator stats to an output device.

Reimplemented from FMalloc.

Definition at line 75 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

◆ Exec()

virtual bool FMallocThreadSafeProxy::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 90 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

◆ Free()

virtual void FMallocThreadSafeProxy::Free ( void * Ptr)
inlineoverridevirtual

Free

Implements FMalloc.

Definition at line 58 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

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

Definition at line 103 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

◆ GetAllocatorStats()

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

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

Reimplemented from FMalloc.

Definition at line 68 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

◆ GetDescriptiveName()

virtual const TCHAR * FMallocThreadSafeProxy::GetDescriptiveName ( )
inlineoverridevirtual

Gets descriptive name for logging purposes.

Returns
pointer to human-readable malloc name

Reimplemented from FMalloc.

Definition at line 109 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

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

Definition at line 32 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

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

Definition at line 123 of file MallocThreadSafeProxy.h.

◆ Malloc()

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

Malloc

Implements FMalloc.

Definition at line 40 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

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

Definition at line 128 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

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

Definition at line 138 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

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

Definition at line 133 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

◆ Realloc()

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

Realloc

Implements FMalloc.

Definition at line 49 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

◆ Trim()

virtual void FMallocThreadSafeProxy::Trim ( bool bTrimThreadCaches)
inlineoverridevirtual

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

Reimplemented from FMalloc.

Definition at line 116 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

◆ ValidateHeap()

virtual bool FMallocThreadSafeProxy::ValidateHeap ( )
inlineoverridevirtual

Validates the allocator's heap

Reimplemented from FMalloc.

Definition at line 84 of file MallocThreadSafeProxy.h.

+ Here is the call graph for this function:

Member Data Documentation

◆ SynchronizationObject

FCriticalSection FMallocThreadSafeProxy::SynchronizationObject
private

Object used for synchronization via a scoped lock

Definition at line 19 of file MallocThreadSafeProxy.h.

◆ UsedMalloc

FMalloc* FMallocThreadSafeProxy::UsedMalloc
private

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

Definition at line 17 of file MallocThreadSafeProxy.h.


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