Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FGenericPlatformMemory Struct Reference

#include <GenericPlatformMemory.h>

+ Inheritance diagram for FGenericPlatformMemory:

Classes

class  FBasicVirtualMemoryBlock
 
struct  FSharedMemoryRegion
 

Public Types

enum  EMemoryCounterRegion {
  MCR_Invalid , MCR_Physical , MCR_GPU , MCR_GPUSystem ,
  MCR_TexturePool , MCR_StreamingPool , MCR_UsedStreamingPool , MCR_GPUDefragPool ,
  MCR_PhysicalLLM , MCR_MAX
}
 
enum  EMemoryAllocatorToUse {
  Ansi , Stomp , TBB , Jemalloc ,
  Binned , Binned2 , Binned3 , Platform ,
  Mimalloc
}
 
enum  ESharedMemoryAccess { Read = (1 << 1) , Write = (1 << 2) }
 

Static Public Member Functions

static void Init ()
 
static void OnOutOfMemory (uint64 Size, uint32 Alignment)
 
static void SetupMemoryPools ()
 
static uint32 GetBackMemoryPoolSize ()
 
static FMallocBaseAllocator ()
 
static FPlatformMemoryStats GetStats ()
 
static uint64 GetMemoryUsedFast ()
 
static void GetStatsForMallocProfiler (FGenericMemoryStats &out_Stats)
 
static const FPlatformMemoryConstantsGetConstants ()
 
static uint32 GetPhysicalGBRam ()
 
static bool PageProtect (void *const Ptr, const SIZE_T Size, const bool bCanRead, const bool bCanWrite)
 
static voidBinnedAllocFromOS (SIZE_T Size)
 
static void BinnedFreeToOS (void *Ptr, SIZE_T Size)
 
static void MiMallocInit ()
 
static void NanoMallocInit ()
 
static bool PtrIsOSMalloc (void *Ptr)
 
static bool IsNanoMallocAvailable ()
 
static bool PtrIsFromNanoMalloc (void *Ptr)
 
static bool BinnedPlatformHasMemoryPoolForThisSize (SIZE_T Size)
 
static void DumpStats (FOutputDevice &Ar)
 
static void DumpPlatformAndAllocatorStats (FOutputDevice &Ar)
 
static EPlatformMemorySizeBucket GetMemorySizeBucket ()
 

Static Public Attributes

static bool bIsOOM
 
static uint64 OOMAllocationSize
 
static uint32 OOMAllocationAlignment
 
static voidBackupOOMMemoryPool
 
static uint32 BackupOOMMemoryPoolSize
 
static EMemoryAllocatorToUse AllocatorToUse
 

Memory functions

struct FGenericStatsUpdater
 
static FORCEINLINE voidMemmove (void *Dest, const void *Src, SIZE_T Count)
 
static FORCEINLINE int32 Memcmp (const void *Buf1, const void *Buf2, SIZE_T Count)
 
static FORCEINLINE voidMemset (void *Dest, uint8 Char, SIZE_T Count)
 
static FORCEINLINE voidMemzero (void *Dest, SIZE_T Count)
 
static FORCEINLINE voidMemcpy (void *Dest, const void *Src, SIZE_T Count)
 
static FORCEINLINE voidBigBlockMemcpy (void *Dest, const void *Src, SIZE_T Count)
 
static FORCEINLINE voidStreamingMemcpy (void *Dest, const void *Src, SIZE_T Count)
 
static FORCEINLINE voidParallelMemcpy (void *Dest, const void *Src, SIZE_T Count, EMemcpyCachePolicy Policy=EMemcpyCachePolicy::StoreCached)
 
static void Memswap (void *Ptr1, void *Ptr2, SIZE_T Size)
 
template<typename T >
static FORCEINLINE T ReadUnaligned (const void *Ptr)
 
template<typename T >
static FORCEINLINE void WriteUnaligned (void *Ptr, const T &InValue)
 
static FSharedMemoryRegionMapNamedSharedMemoryRegion (const FString &Name, bool bCreate, uint32 AccessMode, SIZE_T Size)
 
static bool UnmapNamedSharedMemoryRegion (FSharedMemoryRegion *MemoryRegion)
 
static FORCEINLINE bool SupportsFastVRAMMemory ()
 
static bool IsExtraDevelopmentMemoryAvailable ()
 
static uint64 GetExtraDevelopmentMemorySize ()
 
static bool GetLLMAllocFunctions (void *(*&OutAllocFunction)(size_t), void(*&OutFreeFunction)(void *, size_t), int32 &OutAlignment)
 
static FORCEINLINE void OnLowLevelMemory_Alloc (void const *Pointer, uint64 Size, uint64 Tag)
 
static FORCEINLINE void OnLowLevelMemory_Free (void const *Pointer, uint64 Size, uint64 Tag)
 
static void RegisterCustomLLMTags ()
 
static void UpdateCustomLLMTags ()
 
static bool HasForkPageProtectorEnabled ()
 
template<typename T >
static FORCEINLINE void Valswap (T &A, T &B)
 
static void MemswapGreaterThan8 (void *Ptr1, void *Ptr2, SIZE_T Size)
 
template<typename U >
struct __attribute__ ((packed)) TUnaligned
 
static void InternalUpdateStats (const FPlatformMemoryStats &MemoryStats)
 

Detailed Description

Generic implementation for most platforms, these tend to be unused and unimplemented.

Definition at line 207 of file GenericPlatformMemory.h.

Member Enumeration Documentation

◆ EMemoryAllocatorToUse

Which allocator is being used

Enumerator
Ansi 
Stomp 
TBB 
Jemalloc 
Binned 
Binned2 
Binned3 
Platform 
Mimalloc 

Definition at line 246 of file GenericPlatformMemory.h.

◆ EMemoryCounterRegion

Various memory regions that can be used with memory stats. The exact meaning of the enums are relatively platform-dependent, although the general ones (Physical, GPU) are straightforward. A platform can add more of these, and it won't affect other platforms, other than a minuscule amount of memory for the StatManager to track the max available memory for each region (uses an array FPlatformMemory::MCR_MAX big)

Enumerator
MCR_Invalid 
MCR_Physical 
MCR_GPU 
MCR_GPUSystem 
MCR_TexturePool 
MCR_StreamingPool 
MCR_UsedStreamingPool 
MCR_GPUDefragPool 
MCR_PhysicalLLM 
MCR_MAX 

Definition at line 231 of file GenericPlatformMemory.h.

◆ ESharedMemoryAccess

Flags used for shared memory creation/open

Enumerator
Read 
Write 

Definition at line 265 of file GenericPlatformMemory.h.

Member Function Documentation

◆ __attribute__()

template<typename U >
struct FGenericPlatformMemory::__attribute__ ( (packed) )
inline

Definition at line 611 of file GenericPlatformMemory.h.

+ Here is the call graph for this function:

◆ BaseAllocator()

static FMalloc * FGenericPlatformMemory::BaseAllocator ( )
static
Returns
the default allocator.

◆ BigBlockMemcpy()

static FORCEINLINE void * FGenericPlatformMemory::BigBlockMemcpy ( void * Dest,
const void * Src,
SIZE_T Count )
inlinestatic

Memcpy optimized for big blocks.

Definition at line 577 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ BinnedAllocFromOS()

static void * FGenericPlatformMemory::BinnedAllocFromOS ( SIZE_T Size)
static

Allocates pages from the OS.

Parameters
SizeSize to allocate, not necessarily aligned
Returns
OS allocated pointer for use by binned allocator

◆ BinnedFreeToOS()

static void FGenericPlatformMemory::BinnedFreeToOS ( void * Ptr,
SIZE_T Size )
static

Returns pages allocated by BinnedAllocFromOS to the OS.

Parameters
Apointer previously returned from BinnedAllocFromOS
Sizesize of the allocation previously passed to BinnedAllocFromOS

◆ BinnedPlatformHasMemoryPoolForThisSize()

static bool FGenericPlatformMemory::BinnedPlatformHasMemoryPoolForThisSize ( SIZE_T Size)
inlinestatic

Some platforms may pool allocations of this size to reduce OS calls. This function serves as a hint for BinnedMalloc's CachedOSPageAllocator so it does not cache these allocations additionally

Definition at line 528 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ DumpPlatformAndAllocatorStats()

static void FGenericPlatformMemory::DumpPlatformAndAllocatorStats ( FOutputDevice & Ar)
static

Dumps basic platform memory statistics and allocator specific statistics into the specified output device.

◆ DumpStats()

static void FGenericPlatformMemory::DumpStats ( FOutputDevice & Ar)
static

Dumps basic platform memory statistics into the specified output device.

◆ GetBackMemoryPoolSize()

static uint32 FGenericPlatformMemory::GetBackMemoryPoolSize ( )
inlinestatic
Returns
how much memory the platform should pre-allocate for crash handling (this will be allocated ahead of time, and freed when system runs out of memory).

Definition at line 325 of file GenericPlatformMemory.h.

◆ GetConstants()

static const FPlatformMemoryConstants & FGenericPlatformMemory::GetConstants ( )
static
Returns
platform specific memory constants.

◆ GetExtraDevelopmentMemorySize()

static uint64 FGenericPlatformMemory::GetExtraDevelopmentMemorySize ( )
static

Returns >0 if debug memory has been assigned to the title for general use. Only applies to platforms with fixed memory and no paging.

◆ GetLLMAllocFunctions()

static bool FGenericPlatformMemory::GetLLMAllocFunctions ( void *(*&)(size_t) OutAllocFunction,
void(*&)(void *, size_t) OutFreeFunction,
int32 & OutAlignment )
static

This function sets AllocFunction and FreeFunction and returns true, or just returns false. These functions are the platform dependant low low low level functions that LLM uses to allocate memory.

◆ GetMemorySizeBucket()

static EPlatformMemorySizeBucket FGenericPlatformMemory::GetMemorySizeBucket ( )
static

Return which "high level", per platform, memory bucket we are in

◆ GetMemoryUsedFast()

static uint64 FGenericPlatformMemory::GetMemoryUsedFast ( )
inlinestatic
Returns
memory used for platforms that can do it quickly (without affecting stat unit much)

Definition at line 344 of file GenericPlatformMemory.h.

◆ GetPhysicalGBRam()

static uint32 FGenericPlatformMemory::GetPhysicalGBRam ( )
static
Returns
approximate physical RAM in GB.

◆ GetStats()

static FPlatformMemoryStats FGenericPlatformMemory::GetStats ( )
static
Returns
platform specific current memory statistics.

◆ GetStatsForMallocProfiler()

static void FGenericPlatformMemory::GetStatsForMallocProfiler ( FGenericMemoryStats & out_Stats)
static

Writes all platform specific current memory statistics in the format usable by the malloc profiler.

◆ HasForkPageProtectorEnabled()

static bool FGenericPlatformMemory::HasForkPageProtectorEnabled ( )
inlinestatic

Returns true if Protecting the parent processes pages has been enabled Only supported on platforms that support forking

Definition at line 780 of file GenericPlatformMemory.h.

◆ Init()

static void FGenericPlatformMemory::Init ( )
static

Initializes platform memory specific constants.

◆ InternalUpdateStats()

static void FGenericPlatformMemory::InternalUpdateStats ( const FPlatformMemoryStats & MemoryStats)
staticprotected

Updates platform specific stats. This method is called through FGenericStatsUpdater from the task graph thread.

◆ IsExtraDevelopmentMemoryAvailable()

static bool FGenericPlatformMemory::IsExtraDevelopmentMemoryAvailable ( )
static

Returns true if debug memory has been assigned to the title for general use. Only applies to platforms with fixed memory and no paging.

◆ IsNanoMallocAvailable()

static bool FGenericPlatformMemory::IsNanoMallocAvailable ( )
inlinestatic

Nano Malloc is Apple's tiny block allocator. Does the Nano malloc zone exist?

Returns
True if Nano malloc is enabled and available.

Definition at line 430 of file GenericPlatformMemory.h.

◆ MapNamedSharedMemoryRegion()

static FSharedMemoryRegion * FGenericPlatformMemory::MapNamedSharedMemoryRegion ( const FString & Name,
bool bCreate,
uint32 AccessMode,
SIZE_T Size )
static

Maps a named shared memory region into process address space (creates or opens it)

Parameters
Nameunique name of the shared memory region (should not contain [back]slashes to remain cross-platform).
bCreatewhether we're creating it or just opening existing (created by some other process).
AccessModemode which we will be accessing it (use values from ESharedMemoryAccess)
Sizesize of the buffer (should be >0. Also, the real size is subject to platform limitations and may be increased to match page size)
Returns
pointer to FSharedMemoryRegion (or its descendants) if successful, NULL if not.

◆ Memcmp()

static FORCEINLINE int32 FGenericPlatformMemory::Memcmp ( const void * Buf1,
const void * Buf2,
SIZE_T Count )
inlinestatic

Definition at line 556 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ Memcpy()

static FORCEINLINE void * FGenericPlatformMemory::Memcpy ( void * Dest,
const void * Src,
SIZE_T Count )
inlinestatic

Definition at line 571 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ Memmove()

static FORCEINLINE void * FGenericPlatformMemory::Memmove ( void * Dest,
const void * Src,
SIZE_T Count )
inlinestatic

Copies count bytes of characters from Src to Dest. If some regions of the source area and the destination overlap, memmove ensures that the original source bytes in the overlapping region are copied before being overwritten. NOTE: make sure that the destination buffer is the same size or larger than the source buffer!

Definition at line 551 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ Memset()

static FORCEINLINE void * FGenericPlatformMemory::Memset ( void * Dest,
uint8 Char,
SIZE_T Count )
inlinestatic

Definition at line 561 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ Memswap()

static void FGenericPlatformMemory::Memswap ( void * Ptr1,
void * Ptr2,
SIZE_T Size )
inlinestatic

Definition at line 611 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ MemswapGreaterThan8()

static void FGenericPlatformMemory::MemswapGreaterThan8 ( void * Ptr1,
void * Ptr2,
SIZE_T Size )
staticprivate
+ Here is the caller graph for this function:

◆ Memzero()

static FORCEINLINE void * FGenericPlatformMemory::Memzero ( void * Dest,
SIZE_T Count )
inlinestatic

Definition at line 566 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ MiMallocInit()

static void FGenericPlatformMemory::MiMallocInit ( )
inlinestatic

Performs initial setup for MiMalloc. This is a noop on platforms that do not support MiMalloc, or when MIMALLOC_ENABLED is not defined.

Definition at line 396 of file GenericPlatformMemory.h.

◆ NanoMallocInit()

static void FGenericPlatformMemory::NanoMallocInit ( )
inlinestatic

Performs initial setup for Nano malloc. This is a noop on non-apple platforms

Definition at line 404 of file GenericPlatformMemory.h.

◆ OnLowLevelMemory_Alloc()

static FORCEINLINE void FGenericPlatformMemory::OnLowLevelMemory_Alloc ( void const * Pointer,
uint64 Size,
uint64 Tag )
inlinestatic

Called for all default tracker LLM allocations and frees, when LLM is enabled. Provides a single alloc/free hook that platforms can implement to support platform specific memory analysis tools.

Definition at line 762 of file GenericPlatformMemory.h.

◆ OnLowLevelMemory_Free()

static FORCEINLINE void FGenericPlatformMemory::OnLowLevelMemory_Free ( void const * Pointer,
uint64 Size,
uint64 Tag )
inlinestatic

Definition at line 763 of file GenericPlatformMemory.h.

◆ OnOutOfMemory()

static void FGenericPlatformMemory::OnOutOfMemory ( uint64 Size,
uint32 Alignment )
static
+ Here is the caller graph for this function:

◆ PageProtect()

static bool FGenericPlatformMemory::PageProtect ( void *const Ptr,
const SIZE_T Size,
const bool bCanRead,
const bool bCanWrite )
static

Changes the protection on a region of committed pages in the virtual address space.

Parameters
PtrAddress to the starting page of the region of pages whose access protection attributes are to be changed.
SizeThe size of the region whose access protection attributes are to be changed, in bytes.
bCanReadCan the memory be read.
bCanWriteCan the memory be written to.
Returns
True if the specified pages' protection mode was changed.

◆ ParallelMemcpy()

static FORCEINLINE void * FGenericPlatformMemory::ParallelMemcpy ( void * Dest,
const void * Src,
SIZE_T Count,
EMemcpyCachePolicy Policy = EMemcpyCachePolicy::StoreCached )
inlinestatic

On some platforms memcpy can be distributed over multiple threads for throughput.

Definition at line 589 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ PtrIsFromNanoMalloc()

static bool FGenericPlatformMemory::PtrIsFromNanoMalloc ( void * Ptr)
inlinestatic

Was this pointer allocated by in the Nano Malloc Zone? Currently only Apple platforms implement this to detect small block allocations.

Parameters
Thepointer to query
Returns
True if this pointer is in the Nano Malloc Region

Definition at line 443 of file GenericPlatformMemory.h.

◆ PtrIsOSMalloc()

static bool FGenericPlatformMemory::PtrIsOSMalloc ( void * Ptr)
inlinestatic

Was this pointer allocated by the OS malloc? Currently only Apple platforms implement this to detect small block allocations.

Parameters
Thepointer to query
Returns
True if this pointer was allocated by the OS.

Definition at line 417 of file GenericPlatformMemory.h.

◆ ReadUnaligned()

template<typename T >
static FORCEINLINE T FGenericPlatformMemory::ReadUnaligned ( const void * Ptr)
inlinestatic

Loads a simple POD type from unaligned memory.

Parameters
Ptrunaligned memory of at least size sizeof(T)
Returns
Value at Ptr

Definition at line 691 of file GenericPlatformMemory.h.

◆ RegisterCustomLLMTags()

static void FGenericPlatformMemory::RegisterCustomLLMTags ( )
inlinestatic

Called once at LLM initialization time to let the platform add any custom tags

Definition at line 768 of file GenericPlatformMemory.h.

◆ SetupMemoryPools()

static void FGenericPlatformMemory::SetupMemoryPools ( )
static

Initializes the memory pools, should be called by the init function.

◆ StreamingMemcpy()

static FORCEINLINE void * FGenericPlatformMemory::StreamingMemcpy ( void * Dest,
const void * Src,
SIZE_T Count )
inlinestatic

On some platforms memcpy optimized for big blocks that avoid L2 cache pollution are available

Definition at line 583 of file GenericPlatformMemory.h.

+ Here is the caller graph for this function:

◆ SupportsFastVRAMMemory()

static FORCEINLINE bool FGenericPlatformMemory::SupportsFastVRAMMemory ( )
inlinestatic

Gets whether this platform supports Fast VRAM memory Ie, whether TexCreate_FastVRAM flags actually mean something or not

Returns
bool true if supported, false if not

Definition at line 735 of file GenericPlatformMemory.h.

◆ UnmapNamedSharedMemoryRegion()

static bool FGenericPlatformMemory::UnmapNamedSharedMemoryRegion ( FSharedMemoryRegion * MemoryRegion)
static

Unmaps a name shared memory region

Parameters
MemoryRegionan object that encapsulates a shared memory region (will be destroyed even if function fails!)
Returns
true if successful

◆ UpdateCustomLLMTags()

static void FGenericPlatformMemory::UpdateCustomLLMTags ( )
inlinestatic

Called once per frame when LLM is collating the data for the current frame. Can be used to set platform-specific calculated tag data via SetTagAmountForTracker

Definition at line 774 of file GenericPlatformMemory.h.

◆ Valswap()

template<typename T >
static FORCEINLINE void FGenericPlatformMemory::Valswap ( T & A,
T & B )
inlinestaticprivate

Definition at line 597 of file GenericPlatformMemory.h.

◆ WriteUnaligned()

template<typename T >
static FORCEINLINE void FGenericPlatformMemory::WriteUnaligned ( void * Ptr,
const T & InValue )
inlinestatic

Stores a simple POD type to unaligned memory.

Parameters
Ptrunaligned memory of at least size sizeof(T)
Valuevalue to write at Ptr

Definition at line 703 of file GenericPlatformMemory.h.

Friends And Related Symbol Documentation

◆ FGenericStatsUpdater

friend struct FGenericStatsUpdater
friend

Definition at line 783 of file GenericPlatformMemory.h.

Member Data Documentation

◆ AllocatorToUse

EMemoryAllocatorToUse FGenericPlatformMemory::AllocatorToUse
static

Current allocator

Definition at line 260 of file GenericPlatformMemory.h.

◆ BackupOOMMemoryPool

void* FGenericPlatformMemory::BackupOOMMemoryPool
static

Preallocated buffer to delete on out of memory. Used by OOM handling and crash reporting.

Definition at line 219 of file GenericPlatformMemory.h.

◆ BackupOOMMemoryPoolSize

uint32 FGenericPlatformMemory::BackupOOMMemoryPoolSize
static

Size of BackupOOMMemoryPool in bytes.

Definition at line 222 of file GenericPlatformMemory.h.

◆ bIsOOM

bool FGenericPlatformMemory::bIsOOM
static

Set to true if we encounters out of memory.

Definition at line 210 of file GenericPlatformMemory.h.

◆ OOMAllocationAlignment

uint32 FGenericPlatformMemory::OOMAllocationAlignment
static

Set to alignment of allocation that triggered out of memory, zero otherwise.

Definition at line 216 of file GenericPlatformMemory.h.

◆ OOMAllocationSize

uint64 FGenericPlatformMemory::OOMAllocationSize
static

Set to size of allocation that triggered out of memory, zero otherwise.

Definition at line 213 of file GenericPlatformMemory.h.


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