Karma Engine
Loading...
Searching...
No Matches
Karma::FUObjectAllocator Class Reference

#include <UObjectAllocator.h>

Public Member Functions

 FUObjectAllocator ()
 
void AllocatePermanentObjectPool (int32_t InPermanentObjectPoolSize)
 
void Initialize (uint8_t *pMemoryStart, size_t elemetSizeBytes, size_t numberOfElemets)
 
void BootMessage ()
 
FORCEINLINE bool ResidesInPermanentPool (const UObjectBase *Object) const
 
UObjectBaseAllocateUObject (size_t Size, size_t Alignment, bool bAllowPermanent)
 
void DumpUObjectsInformation (void *InObject, const std::string &InName, size_t InSize, size_t InAlignment, class UClass *InClass)
 
void RegisterUObjectsStatisticsCallback (FUObjectAllocatorCallback dumpCallback)
 
uint8_t * GetPermanentObjectPoolTail () const
 
uint8_t * GetPermanentObjectPool () const
 
uint32_t GetPermanentPoolSize () const
 
uint8_t * GetPermanentObjectPoolEnd () const
 
uint32_t GetBareUObjectSize () const
 
uint32_t GetAlignedUObjectSize () const
 
uint32_t GetNumberOfUObjects () const
 

Detailed Description

A pool allocator for Karma's UObjects. I'd higly recommend Gregory's Game Engine Architecture section 5.2 for introductory level and practical approach to memory system.

A modular memory system https://github.com/ravimohan1991/cppGameMemorySystem Karma's take https://github.com/ravimohan1991/KarmaEngine/wiki/Karma-Smriti

Constructor & Destructor Documentation

◆ FUObjectAllocator()

Karma::FUObjectAllocator::FUObjectAllocator ( )
inline

Constructor, initializes to no permanent object pool

Member Function Documentation

◆ AllocatePermanentObjectPool()

void Karma::FUObjectAllocator::AllocatePermanentObjectPool ( int32_t InPermanentObjectPoolSize)

Allocates and initializes the permanent object pool. For legacy purpose.

Parameters
InPermanentObjectPoolSizesize of permanent object pool

Allocates and initializes the permanent object pool

Parameters
InPermanentObjectPoolSizesize of permanent object pool

◆ AllocateUObject()

UObjectBase * Karma::FUObjectAllocator::AllocateUObject ( size_t Size,
size_t Alignment,
bool bAllowPermanent )

Allocates a UObjectBase from the free store or the permanent object pool Note: We are returning UObjectBase pointer because ue does so. Else void pointer could have done the job, since what we are returning is not really a UObjectBase.

Parameters
Sizesize of uobject to allocate
Alignmentalignment of uobject to allocate
bAllowPermanentif true, allow allocation in the permanent object pool, if it fits
Returns
newly allocated UObjectBase (not really a UObjectBase yet, no constructor like thing has been called).

◆ BootMessage()

void Karma::FUObjectAllocator::BootMessage ( )

Prints a debugf message to allow tuning

◆ DumpUObjectsInformation()

void Karma::FUObjectAllocator::DumpUObjectsInformation ( void * InObject,
const std::string & InName,
size_t InSize,
size_t InAlignment,
class UClass * InClass )

A callback based routine for curating statistics of UObjects being allocated

◆ GetAlignedUObjectSize()

uint32_t Karma::FUObjectAllocator::GetAlignedUObjectSize ( ) const
inline

Get total boundary aligned size of UObject

◆ GetBareUObjectSize()

uint32_t Karma::FUObjectAllocator::GetBareUObjectSize ( ) const
inline

Get the bare cumulatice size of UObjects

◆ GetNumberOfUObjects()

uint32_t Karma::FUObjectAllocator::GetNumberOfUObjects ( ) const
inline

Get total number of UObjects

◆ GetPermanentObjectPool()

uint8_t * Karma::FUObjectAllocator::GetPermanentObjectPool ( ) const
inline

Get the begining of object pool

◆ GetPermanentObjectPoolEnd()

uint8_t * Karma::FUObjectAllocator::GetPermanentObjectPoolEnd ( ) const
inline

Get the address of memory pool block ending

◆ GetPermanentObjectPoolTail()

uint8_t * Karma::FUObjectAllocator::GetPermanentObjectPoolTail ( ) const
inline

Returns a UObjectBase to the free store, unless it is in the permanent object pool

Parameters
Objectobject to free Get the current position of objectpool tail

◆ GetPermanentPoolSize()

uint32_t Karma::FUObjectAllocator::GetPermanentPoolSize ( ) const
inline

Get the total pool size in bytes

◆ Initialize()

void Karma::FUObjectAllocator::Initialize ( uint8_t * pMemoryStart,
size_t elemetSizeBytes,
size_t numberOfElemets )

Initializes the pool allocator with alloted memory variables

Parameters
pMemoryStartPointer to the start of the pool memory
elementSizeBytesSize of each element in bytes
numberOfElementsTota number of UObjects envisoned
See also
KarmaSmriti::StartUp()

◆ ResidesInPermanentPool()

FORCEINLINE bool Karma::FUObjectAllocator::ResidesInPermanentPool ( const UObjectBase * Object) const
inline

Checks whether object is part of permanent object pool.

Parameters
Objectobject to test as a member of permanent object pool
Returns
true if object is part of permanent object pool, false otherwise

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