KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::FUObjectAllocator Class Reference

A pool allocator for Karma's UObjects. More...

#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)
 Allocates a UObjectBase from the free store or the permanent object pool.
 
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

Since
Karma 1.0.0

Member Function Documentation

◆ AllocatePermanentObjectPool()

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

Allocates and initializes the permanent object pool.

Remarks
For legacy purpose. Use FUObjectAllocator::Initialize instead
Parameters
InPermanentObjectPoolSizesize of permanent object pool
Since
Karma 1.0.0

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

Remarks
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 (in bytes) 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).
Since
Karma 1.0.0

◆ BootMessage()

void Karma::FUObjectAllocator::BootMessage ( )

Prints a debugf message to allow tuning

Since
Karma 1.0.0

◆ 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

Since
Karma 1.0.0

◆ GetAlignedUObjectSize()

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

Get total boundary aligned size of UObject

Since
Karma 1.0.0

◆ GetBareUObjectSize()

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

Get the bare cumulatice size of UObjects

Since
Karma 1.0.0

◆ GetNumberOfUObjects()

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

Get total number of UObjects

Since
Karma 1.0.0

◆ GetPermanentObjectPool()

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

Get the begining of object pool

Since
Karma 1.0.0

◆ GetPermanentObjectPoolEnd()

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

Get the address of memory pool block ending

Since
Karma 1.0.0

◆ 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
Since
Karma 1.0.0

◆ GetPermanentPoolSize()

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

Get the total pool size in bytes

Since
Karma 1.0.0

◆ 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()
Since
Karma 1.0.0

◆ RegisterUObjectsStatisticsCallback()

void Karma::FUObjectAllocator::RegisterUObjectsStatisticsCallback ( FUObjectAllocatorCallback dumpCallback)

Routine for registering callback function for statistics purposes

See also
FUObjectAllocator::DumpUObjectsInformation
Remarks
Use // Register UObject statistics dump RegisterUObjectsStatisticsCallback(e.g KarmaGuiMesa::DumpUObjectStatistics or some routine to be registered);
Since
Karma 1.0.0

◆ 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
Since
Karma 1.0.0

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