Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::MemoryManagerGlobalHandle Class Reference

Global Handle Memory Manager helper class. More...

Inheritance diagram for Burger::MemoryManagerGlobalHandle:
Collaboration diagram for Burger::MemoryManagerGlobalHandle:

Public Member Functions

 MemoryManagerGlobalHandle (uintptr_t uDefaultMemorySize=kSystemMemoryChuckSize, uint_t uDefaultHandleCount=kDefaultHandleCount, uintptr_t uMinReserveSize=kSystemMemoryReservedSize) noexcept
 Attaches a Burger::MemoryManagerHandle class to the global memory manager.
 
 ~MemoryManagerGlobalHandle ()
 Releases a Burger::MemoryManagerGlobalHandle class from the global memory manager.
 
- Public Member Functions inherited from Burger::MemoryManagerHandle
 MemoryManagerHandle (uintptr_t uDefaultMemorySize=kSystemMemoryChuckSize, uint_t uDefaultHandleCount=kDefaultHandleCount, uintptr_t uMinReserveSize=kSystemMemoryReservedSize) noexcept
 Initialize the Handle based Memory Manager.
 
 ~MemoryManagerHandle ()
 The destructor for the Handle based Memory Manager.
 
uintptr_t GetTotalAllocatedMemory (void) const noexcept
 Returns the total allocated memory used by pointers and handles in bytes.
 
void * alloc (uintptr_t uSize) noexcept
 Allocate fixed memory.
 
void free (const void *pInput) noexcept
 Release fixed memory.
 
void * realloc (const void *pInput, uintptr_t uSize) noexcept
 Resize a preexisting allocated block of memory.
 
void shutdown (void) noexcept
 Shutdown the handle based Memory Manager.
 
void ** alloc_handle (uintptr_t uSize, uint_t uFlags=0) noexcept
 Allocates a block of memory.
 
void free_handle (void **ppInput) noexcept
 Dispose of a memory handle into the free handle pool.
 
void ** ReallocHandle (void **ppInput, uintptr_t uSize) noexcept
 Resize a handle.
 
void ** RefreshHandle (void **ppInput) noexcept
 If the handle was purged, reallocate memory to it.
 
void ** FindHandle (const void *pInput) noexcept
 Search the handle tree for a pointer.
 
uintptr_t GetTotalFreeMemory (void) noexcept
 Returns the total free space with purging.
 
void clear_purge_flag (void **ppInput) noexcept
 
void set_purge_flag (void **ppInput) noexcept
 Set the purge flag to a given handle.
 
void SetLockedState (void **ppInput, uint_t uFlag) noexcept
 Set the current purge and lock flags of the handle.
 
void Purge (void **ppInput) noexcept
 Move a handle into the purged list.
 
uint_t PurgeHandles (uintptr_t uSize) noexcept
 Purges handles until the amount of memory requested is freed.
 
void CompactHandles (void) noexcept
 Compact all of the movable blocks together.
 
void dump_handles (void) noexcept
 Display all the memory.
 
- Public Member Functions inherited from Burger::MemoryManager
void * alloc (uintptr_t uSize) noexcept
 Allocate memory.
 
void free (const void *pInput) noexcept
 Release memory.
 
void * realloc (const void *pInput, uintptr_t uSize) noexcept
 Reallocate memory.
 
void shutdown (void) noexcept
 Shut down the memory manager.
 
void * alloc_clear (uintptr_t uSize) noexcept
 Allocate a block of pre-zeroed memory.
 

Private Member Functions

 MemoryManagerGlobalHandle (const MemoryManagerGlobalHandle &)=delete
 
MemoryManagerGlobalHandleoperator= (const MemoryManagerGlobalHandle &)=delete
 
 MemoryManagerGlobalHandle (MemoryManagerGlobalHandle &&)=delete
 
MemoryManagerGlobalHandleoperator= (MemoryManagerGlobalHandle &&)=delete
 

Private Attributes

MemoryManagerm_pPrevious
 Pointer to the previous memory manager.
 

Additional Inherited Members

- Public Types inherited from Burger::MemoryManagerHandle
enum  eMemoryStage { kStageCompact , kStagePurge , kStageHailMary , kStageGiveup }
 
typedef void(*) MemPurgeProc(void *pThis, eMemoryStage uStage)
 Function prototype for user supplied garbage collection subroutine.
 
- Public Types inherited from Burger::MemoryManager
typedef void *(*) ProcAlloc(MemoryManager *pThis, uintptr_t uSize)
 Function prototype for allocating memory.
 
typedef void(*) ProcFree(MemoryManager *pThis, const void *pInput)
 Function prototype for releasing memory.
 
typedef void *(*) ProcRealloc(MemoryManager *pThis, const void *pInput, uintptr_t uSize)
 Function prototype for reallocating memory.
 
typedef void(*) ProcShutdown(MemoryManager *pThis)
 Function prototype for destructor.
 
- Static Public Member Functions inherited from Burger::MemoryManagerHandle
static uintptr_t GetSize (void **ppInput) noexcept
 Returns the size of a memory handle.
 
static uintptr_t GetSize (const void *pInput) noexcept
 Returns the size of a memory pointer.
 
static void * lock (void **ppInput) noexcept
 Set the lock flag to a given handle and return the data pointer.
 
static void unlock (void **ppInput) noexcept
 Clear the lock flag to a given handle.
 
static void set_ID (void **ppInput, uint_t uID) noexcept
 Set a user supplied ID value for a handle.
 
static uint_t GetLockedState (void **ppInput) noexcept
 Get the current purge and lock flags of the handle.
 
- Static Public Member Functions inherited from Burger::MemoryManager
static void shutdown (MemoryManager *pThis) noexcept
 Default memory manager destructor.
 
- Public Attributes inherited from Burger::MemoryManager
ProcAlloc m_pAlloc
 Pointer to allocation function.
 
ProcFree m_pFree
 Pointer to memory release function.
 
ProcRealloc m_pRealloc
 Pointer to the memory reallocation function.
 
ProcShutdown m_pShutdown
 Pointer to the shutdown function.
 
- Static Public Attributes inherited from Burger::MemoryManagerHandle
static const uint32_t kFlagLocked = 0x80
 Set if the memory handle is temporarily locked.
 
static const uint32_t kFlagFixed = 0x40
 Set if the memory cannot be moved (High memory)
 
static const uint32_t kFlagMalloc = 0x20
 Set if the memory was allocated with malloc()
 
static const uint32_t kFlagPurgable = 0x01
 Set if the handle is purgable.
 
static const uintptr_t kAlignment = 16
 Memory alignment, power of 2, larger or equal to sizeof(void*)
 
static const uint32_t kDefaultHandleCount = 512
 Default starting number of memory handles.
 
static const uintptr_t kSystemMemoryChuckSize = 0x1000000
 Default memory chunk allocation size from system.
 
static const uintptr_t kSystemMemoryReservedSize = 0x40000
 Default reserved system memory size.
 
static const uint32_t kMemoryIDUnused = UINT32_MAX - 2
 Unused handle memory ID.
 
static const uint32_t kMemoryIDFree = UINT32_MAX - 1
 Free handle memory ID.
 
static const uint32_t kMemoryIDReserved = UINT32_MAX
 Reserved handle memory ID.
 

Detailed Description

Global Handle Memory Manager helper class.


This class is a helper that attaches a Burger::MemoryManagerHandle class to the global memory manager. When this instance shuts down, it will remove itself from the global memory manager.

See also
Burger::GlobalMemoryManager and Burger::MemoryManagerHandle

Constructor & Destructor Documentation

◆ MemoryManagerGlobalHandle() [1/3]

Burger::MemoryManagerGlobalHandle::MemoryManagerGlobalHandle ( const MemoryManagerGlobalHandle & )
privatedelete

◆ MemoryManagerGlobalHandle() [2/3]

Burger::MemoryManagerGlobalHandle::MemoryManagerGlobalHandle ( MemoryManagerGlobalHandle && )
privatedelete

◆ MemoryManagerGlobalHandle() [3/3]

Burger::MemoryManagerGlobalHandle::MemoryManagerGlobalHandle ( uintptr_t uDefaultMemorySize = kSystemMemoryChuckSize,
uint_t uDefaultHandleCount = kDefaultHandleCount,
uintptr_t uMinReserveSize = kSystemMemoryReservedSize )
noexcept

Attaches a Burger::MemoryManagerHandle class to the global memory manager.


When this class is created, it will automatically attach itself to the global memory manager.

◆ ~MemoryManagerGlobalHandle()

Burger::MemoryManagerGlobalHandle::~MemoryManagerGlobalHandle ( )

Releases a Burger::MemoryManagerGlobalHandle class from the global memory manager.


When this class is released, it will automatically remove itself to the global memory manager.

Member Function Documentation

◆ operator=() [1/2]

MemoryManagerGlobalHandle & Burger::MemoryManagerGlobalHandle::operator= ( const MemoryManagerGlobalHandle & )
privatedelete

◆ operator=() [2/2]

MemoryManagerGlobalHandle & Burger::MemoryManagerGlobalHandle::operator= ( MemoryManagerGlobalHandle && )
privatedelete

Member Data Documentation

◆ m_pPrevious

MemoryManager* Burger::MemoryManagerGlobalHandle::m_pPrevious
private

Pointer to the previous memory manager.