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::MemoryManagerHandle Class Reference

Handle based Memory Manager. More...

Inheritance diagram for Burger::MemoryManagerHandle:
Collaboration diagram for Burger::MemoryManagerHandle:

Classes

struct  Handle_t
 Structure describing an allocated chunk of memory. More...
 
struct  SystemBlock_t
 

Public Types

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.
 

Public Member Functions

 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.
 

Static Public Member Functions

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.
 

Static Public Attributes

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.
 

Private Member Functions

 MemoryManagerHandle (const MemoryManagerHandle &)=delete
 
MemoryManagerHandleoperator= (const MemoryManagerHandle &)=delete
 
 MemoryManagerHandle (MemoryManagerHandle &&)=delete
 
MemoryManagerHandleoperator= (MemoryManagerHandle &&)=delete
 
Handle_tAllocNewHandle (void) noexcept
 Allocate a new handle record.
 
void GrabMemoryRange (void *pData, uintptr_t uLength, Handle_t *pParent, Handle_t *pHandle) noexcept
 Remove a range of memory from the free memory pool.
 
void ReleaseMemoryRange (void *pData, uintptr_t uLength, Handle_t *pParent) noexcept
 Add a range of memory to the free memory list.
 
void PrintHandles (const Handle_t *pFirst, const Handle_t *pLast, uint_t bNoCheck) noexcept
 Print the state of the memory to Burger::Debug::String(const char *)
 

Static Private Member Functions

static void * alloc_proc (MemoryManager *pThis, uintptr_t uSize) noexcept
 Allocate fixed memory.
 
static void free_proc (MemoryManager *pThis, const void *pInput) noexcept
 Release fixed memory.
 
static void * realloc_proc (MemoryManager *pThis, const void *pInput, uintptr_t uSize) noexcept
 Resize a preexisting allocated block of memory.
 
static void shutdown_proc (MemoryManager *pThis) noexcept
 Shutdown the handle based Memory Manager.
 

Private Attributes

SystemBlock_tm_pSystemMemoryBlocks
 Linked list of memory blocks taken from the system.
 
MemPurgeProc m_MemPurgeCallBack
 Callback before memory purging.
 
void * m_pMemPurge
 User pointer for memory purge.
 
uintptr_t m_uTotalAllocatedMemory
 All of the memory currently allocated.
 
uintptr_t m_uTotalSystemMemory
 Total allocated system memory.
 
Handle_tm_pFreeHandle
 Pointer to the free handle list.
 
uint_t m_uTotalHandleCount
 Number of handles allocated.
 
Handle_t m_LowestUsedMemory
 First used memory handle (Start of linked list)
 
Handle_t m_HighestUsedMemory
 Last used memory handle (End of linked list)
 
Handle_t m_FreeMemoryChunks
 Free handle list.
 
Handle_t m_PurgeHands
 Purged handle list.
 
Handle_t m_PurgeHandleFiFo
 Purged handle linked list.
 
Mutex m_Lock
 Lock for multi-threading support.
 

Additional Inherited Members

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

Detailed Description

Handle based Memory Manager.


This class allocates and releases memory using movable memory blocks and can allocate from the top and bottom of memory if needed. Fixed memory blocks are allocate from the top of memory and movable memory blocks are allocated from the bottom. Movable blocks can be marked as purgeable so in low memory situations, the memory can be freed without the main application's knowledge. To accomplish this, any access to a handle must be first locked and then tested if it's been purged. If it's purged, the memory must be reallocated and reloaded with the data. It's mostly used by the resource, texture and audio managers to cache in data chunks that can be reloaded from disk if need be.

Member Typedef Documentation

◆ MemPurgeProc

void( *) Burger::MemoryManagerHandle::MemPurgeProc(void *pThis, eMemoryStage uStage)

Function prototype for user supplied garbage collection subroutine.

Member Enumeration Documentation

◆ eMemoryStage

Enumerator
kStageCompact 

Garbage collection stage to compact memory.

kStagePurge 

Garbage collection stage to purge purgeable memory.

kStageHailMary 

Garbage collection stage to purge and then compact memory.

kStageGiveup 

Critical memory stage, release all possibly releasable memory.

Constructor & Destructor Documentation

◆ MemoryManagerHandle() [1/3]

Burger::MemoryManagerHandle::MemoryManagerHandle ( const MemoryManagerHandle & )
privatedelete

◆ MemoryManagerHandle() [2/3]

Burger::MemoryManagerHandle::MemoryManagerHandle ( MemoryManagerHandle && )
privatedelete

◆ MemoryManagerHandle() [3/3]

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

Initialize the Handle based Memory Manager.


Note
If this class cannot start up due to memory starvation, it will fail with a call to Debug::Fatal()
See also
Burger::MemoryManagerHandle::~MemoryManagerHandle()

◆ ~MemoryManagerHandle()

Burger::MemoryManagerHandle::~MemoryManagerHandle ( )

The destructor for the Handle based Memory Manager.


This calls Burger::MemoryManagerHandle::shutdown(MemoryManager *) to do the actual work

See also
shutdown(MemoryManager *)

Member Function Documentation

◆ alloc()

void * Burger::MemoryManagerHandle::alloc ( uintptr_t uSize)
inlinenoexcept

Allocate fixed memory.


Allocates a pointer to a block of memory in high (Fixed) memory.

Parameters
uSizeNumber of bytes requested
Returns
NULL on allocation failure, valid handle to memory if successful
See also
Burger::MemoryManagerHandle::alloc_proc(MemoryManager *,uintptr_t)

◆ alloc_handle()

void **BURGER_API Burger::MemoryManagerHandle::alloc_handle ( uintptr_t uSize,
uint_t uFlags = 0 )
noexcept

Allocates a block of memory.


Allocates from the top down if fixed and bottom up if movable This routine handles all the magic for memory purging and allocation.

Parameters
uSizeNumber of bytes requested
uFlagsFlags to modify how the memory is allocated, kFlagFixed for fixed memory, 0 for movable memory
Returns
NULL on allocation failure, valid handle to memory if successful
See also
Burger::MemoryManagerHandle::free_handle(void **)

◆ alloc_proc()

void *BURGER_API Burger::MemoryManagerHandle::alloc_proc ( MemoryManager * pThis,
uintptr_t uSize )
staticprivatenoexcept

Allocate fixed memory.


Static function to allocate a pointer to a block of memory in high (Fixed) memory.

Parameters
pThisPointer to the MemoryManagerHandle instance
uSizeSize of memory block request
Returns
Pointer to allocated memory block or NULL on failure or zero byte allocation.
See also
Burger::MemoryManagerHandle::free_proc(MemoryManager *,const void *)

◆ AllocNewHandle()

Burger::MemoryManagerHandle::Handle_t *BURGER_API Burger::MemoryManagerHandle::AllocNewHandle ( void )
privatenoexcept

Allocate a new handle record.


If out of handles in the pool, allocate memory from the operating system in kDefaultHandleCount * sizeof( MemoryManagerHandle::Handle_t) chunks

Returns
Pointer to a new uninitialized Handle_t structure
See also
Burger::MemoryManagerHandle::free_handle(void **)

◆ clear_purge_flag()

void BURGER_API Burger::MemoryManagerHandle::clear_purge_flag ( void ** ppInput)
noexcept

◆ CompactHandles()

void BURGER_API Burger::MemoryManagerHandle::CompactHandles ( void )
noexcept

Compact all of the movable blocks together.


Packs all memory together to reduce or eliminate fragmentation This doesn't alter the handle list in any way but it can move memory around to get rid of empty holes in the memory map.

See also
Burger::MemoryManagerHandle::PurgeHandles(uintptr_t) or Burger::MemoryManagerHandle::Purge(void **)

◆ dump_handles()

void BURGER_API Burger::MemoryManagerHandle::dump_handles ( void )
noexcept

Display all the memory.


See also
Burger::Debug::String(const char *)

◆ FindHandle()

void **BURGER_API Burger::MemoryManagerHandle::FindHandle ( const void * pInput)
noexcept

Search the handle tree for a pointer.


Note
The pointer does NOT have to be the head pointer, just in the domain of the handle Return NULL if the handle is not here.
Parameters
pInputPointer to memory to locate
Returns
MemoryManagerHandle::Handle_t to handle that contains the pointer.
See also
Burger::MemoryManagerHandle::GetSize(void **)

◆ free()

void Burger::MemoryManagerHandle::free ( const void * pInput)
inlinenoexcept

Release fixed memory.


When a pointer is allocated using Burger::MemoryManagerHandle::alloc(uintptr_t), it has a pointer to the handle that references this memory prefixed to it. If the input is not NULL it will use this prefixed pointer to release the handle and therefore this memory.

Parameters
pInputPointer to memory to release, NULL does nothing
See also
Burger::MemoryManagerHandle::free_proc(MemoryManager *,const void *)

◆ free_handle()

void BURGER_API Burger::MemoryManagerHandle::free_handle ( void ** ppInput)
noexcept

Dispose of a memory handle into the free handle pool.


Note
NULL is acceptable input.
Parameters
ppInputHandle to memory allocated by alloc_handle(uintptr_t,uint_t)

◆ free_proc()

void BURGER_API Burger::MemoryManagerHandle::free_proc ( MemoryManager * pThis,
const void * pInput )
staticprivatenoexcept

Release fixed memory.


When a pointer is allocated using Burger::MemoryManagerHandle::alloc_proc() It has a pointer to the handle that references this memory prefixed to it. If the input is not NULL it will use this prefixed pointer to release the handle and therefore this memory.

Parameters
pThisPointer to the MemoryManagerHandle instance
pInputPointer to memory to release, NULL does nothing
See also
Burger::MemoryManagerHandle::alloc_proc(MemoryManager *,uintptr_t)

◆ GetLockedState()

uint_t BURGER_API Burger::MemoryManagerHandle::GetLockedState ( void ** ppInput)
staticnoexcept

Get the current purge and lock flags of the handle.


Parameters
ppInputPointer to valid handle. NULL is invalid
Returns
All the flags from the memory handle. Mask with kFlagLocked to check only for memory being locked
See also
Burger::MemoryManagerHandle::SetLockedState(void **,uint_t)

◆ GetSize() [1/2]

uintptr_t BURGER_API Burger::MemoryManagerHandle::GetSize ( const void * pInput)
staticnoexcept

Returns the size of a memory pointer.


Parameters
pInputValid pointer to allocated memory or NULL
Returns
Number of bytes pointer controls or zero if NULL
See also
Burger::MemoryManagerHandle::GetSize(void **)

◆ GetSize() [2/2]

uintptr_t BURGER_API Burger::MemoryManagerHandle::GetSize ( void ** ppInput)
staticnoexcept

Returns the size of a memory handle.


Parameters
ppInputValid handle of allocated memory, or NULL
Returns
Number of bytes handle controls or zero if empty or NULL input
See also
Burger::MemoryManagerHandle::GetSize(const void *)

◆ GetTotalAllocatedMemory()

uintptr_t Burger::MemoryManagerHandle::GetTotalAllocatedMemory ( void ) const
inlinenoexcept

Returns the total allocated memory used by pointers and handles in bytes.


This is the total number of bytes allocated with all padding necessary for data alignment

See also
Burger::MemoryManagerHandle::GetTotalFreeMemory(void)

◆ GetTotalFreeMemory()

uintptr_t BURGER_API Burger::MemoryManagerHandle::GetTotalFreeMemory ( void )
noexcept

Returns the total free space with purging.


This is accomplished by adding all the memory found in the free memory linked list and then adding all the memory in the used list that can be purged.

Returns
Number of bytes available for allocation including all purgeable memory

◆ GrabMemoryRange()

void BURGER_API Burger::MemoryManagerHandle::GrabMemoryRange ( void * pData,
uintptr_t uLength,
Handle_t * pParent,
Handle_t * pHandle )
privatenoexcept

Remove a range of memory from the free memory pool.


Assume that the memory range is either attached to the end of a free memory segment or the end of a free memory segment.

If not, bad things will happen!

Parameters
pDataPointer to the start of the memory block to reserve
uLengthSize in bytes of the memory block to reserve
pParentPointer to the handle to the allocated handle BEFORE this block
pHandleHandle of the currently free block of memory to allocate from or NULL if the function has to scan manually
See also
Burger::MemoryManagerHandle::ReleaseMemoryRange(void *, uintptr_t,Handle_t *)

◆ lock()

void *BURGER_API Burger::MemoryManagerHandle::lock ( void ** ppInput)
staticnoexcept

Set the lock flag to a given handle and return the data pointer.


Note
This is a boolean flag, not reference counted
Parameters
ppInputPointer to handle to lock or NULL
Returns
Pointer to dereferenced memory or NULL on failure or NULL input
See also
Burger::MemoryManagerHandle::unlock(void **ppInput)

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ PrintHandles()

void BURGER_API Burger::MemoryManagerHandle::PrintHandles ( const Handle_t * pFirst,
const Handle_t * pLast,
uint_t bNoCheck )
privatenoexcept

Print the state of the memory to Burger::Debug::String(const char *)


Walk the linked list of handles from pFirst to pLast and print to the text output a report of the memory handles. All text is printed via Debug::String(const char *)

Parameters
pFirstPointer to the first block to dump
pLastPointer to the block that the dump will cease (Don't dump it)
bNoCheckIf true, print pFirst at all times
See also
Debug::String(const char *)

◆ Purge()

void BURGER_API Burger::MemoryManagerHandle::Purge ( void ** ppInput)
noexcept

Move a handle into the purged list.


This routine will move a handle from the used list into the purged handle list. The handle is not discarded. This is the only way a handle can be placed into the purged list.

It will call Burger::MemoryManagerHandle::ReleaseMemoryRange() to alert the free memory list that there is new free memory.

Parameters
ppInputHandle to allocated memory or NULL to perform no action
See also
Burger::MemoryManagerHandle::PurgeHandles(uintptr_t)

◆ PurgeHandles()

uint_t BURGER_API Burger::MemoryManagerHandle::PurgeHandles ( uintptr_t uSize)
noexcept

Purges handles until the amount of memory requested is freed.


Purges all handles that are purgeable and are greater or equal to the amount of memory It will call Purge(void **) to alert the free memory list that there is free memory.

Parameters
uSizeThe number of bytes to recover before aborting
Returns
TRUE if ANY memory was purged, FALSE is there was no memory to recover
See also
Burger::MemoryManagerHandle::Purge(void **)

◆ realloc()

void * Burger::MemoryManagerHandle::realloc ( const void * pInput,
uintptr_t uSize )
inlinenoexcept

Resize a preexisting allocated block of memory.


Using a pointer to memory, reallocate the size and copy the contents. If a zero length buffer is requested, the input pointer is deallocated, if the input pointer is NULL, a fresh pointer is created.

Parameters
pInputPointer to memory to resize, NULL forces a new block to be created
uSizeSize of memory block request
Returns
Pointer to the new memory block or NULL on failure.
See also
Burger::MemoryManagerHandle::realloc_proc(MemoryManager *, const void *,uintptr_t)

◆ realloc_proc()

void *BURGER_API Burger::MemoryManagerHandle::realloc_proc ( Burger::MemoryManager * pThis,
const void * pInput,
uintptr_t uSize )
staticprivatenoexcept

Resize a preexisting allocated block of memory.


Using a pointer to memory, reallocate the size and copy the contents. If a zero length buffer is requested, the input pointer is deallocated, if the input pointer is NULL, a fresh pointer is created.

Parameters
pThisPointer to the MemoryManagerHandle instance
pInputPointer to memory to resize, NULL forces a new block to be created
uSizeSize of memory block request
Returns
Pointer to the new memory block or NULL on failure.
See also
Burger::MemoryManagerHandle::free_proc(MemoryManager *,const void *)

◆ ReallocHandle()

void **BURGER_API Burger::MemoryManagerHandle::ReallocHandle ( void ** ppInput,
uintptr_t uSize )
noexcept

Resize a handle.


Using a handle to memory, reallocate the size and copy the contents. If the input handle is NULL, then just allocate a new handle, if the size requested is zero then discard the input handle.

Parameters
ppInputHandle to resize
uSizeSize in bytes of the new handle
Returns
Handle of the newly resized memory chunk
See also
Burger::MemoryManagerHandle::free_handle(void **) and Burger::MemoryManagerHandle::alloc_handle(uintptr_t,uint_t)

◆ RefreshHandle()

void **BURGER_API Burger::MemoryManagerHandle::RefreshHandle ( void ** ppInput)
noexcept

If the handle was purged, reallocate memory to it.


Note
The returned handle will REPLACE the handle that was passed in. This code effectively disposes of the previous handle and allocates a new one of the old one's size. If the data is still intact then nothing happens
Parameters
ppInputHandle to be restored
Returns
New handle for data
See also
Burger::MemoryManagerHandle::set_purge_flag(void **,uint_t)

◆ ReleaseMemoryRange()

void BURGER_API Burger::MemoryManagerHandle::ReleaseMemoryRange ( void * pData,
uintptr_t uLength,
Handle_t * pParent )
privatenoexcept

Add a range of memory to the free memory list.


Note
If this memory "Touches" another free memory entry, they will be merged together.
Parameters
pDataPointer to the memory block to return to the pool
uLengthSize of the memory block to return to the pool
pParentPointer to the Handle_t structure of the memory that was released
See also
GrabMemoryRange(void *,uintptr_t,Handle_t *,Handle_t *)

◆ set_ID()

void BURGER_API Burger::MemoryManagerHandle::set_ID ( void ** ppInput,
uint_t uID )
staticnoexcept

Set a user supplied ID value for a handle.


Parameters
ppInputPointer to handle to set the ID
uIDHandle ID

◆ set_purge_flag()

void BURGER_API Burger::MemoryManagerHandle::set_purge_flag ( void ** ppInput)
noexcept

Set the purge flag to a given handle.


Parameters
ppInputHandle to allocated memory or NULL

◆ SetLockedState()

void BURGER_API Burger::MemoryManagerHandle::SetLockedState ( void ** ppInput,
uint_t uFlag )
noexcept

Set the current purge and lock flags of the handle.


Parameters
ppInputHandle to valid memory.
uFlagkFlagPurgable and kFlagLocked are the only valid input flags
See also
Burger::MemoryManagerHandle::GetLockedState(void **)

◆ shutdown()

void Burger::MemoryManagerHandle::shutdown ( void )
inlinenoexcept

Shutdown the handle based Memory Manager.


See also
Burger::MemoryManagerHandle::shutdown_proc(MemoryManager *)

◆ shutdown_proc()

void BURGER_API Burger::MemoryManagerHandle::shutdown_proc ( MemoryManager * pThis)
staticprivatenoexcept

Shutdown the handle based Memory Manager.


Parameters
pThisPointer to the MemoryManagerHandle instance
See also
Burger::MemoryManagerHandle::shutdown(void)

◆ unlock()

void BURGER_API Burger::MemoryManagerHandle::unlock ( void ** ppInput)
staticnoexcept

Clear the lock flag to a given handle.


Note
This is a boolean flag, not reference counted
Parameters
ppInputPointer to handle to unlock or NULL
See also
Burger::MemoryManagerHandle::lock(void **ppInput)

Member Data Documentation

◆ kAlignment

const uintptr_t Burger::MemoryManagerHandle::kAlignment = 16
static

Memory alignment, power of 2, larger or equal to sizeof(void*)

◆ kDefaultHandleCount

const uint32_t Burger::MemoryManagerHandle::kDefaultHandleCount = 512
static

Default starting number of memory handles.

◆ kFlagFixed

const uint32_t Burger::MemoryManagerHandle::kFlagFixed = 0x40
static

Set if the memory cannot be moved (High memory)

◆ kFlagLocked

const uint32_t Burger::MemoryManagerHandle::kFlagLocked = 0x80
static

Set if the memory handle is temporarily locked.

◆ kFlagMalloc

const uint32_t Burger::MemoryManagerHandle::kFlagMalloc = 0x20
static

Set if the memory was allocated with malloc()

◆ kFlagPurgable

const uint32_t Burger::MemoryManagerHandle::kFlagPurgable = 0x01
static

Set if the handle is purgable.

◆ kMemoryIDFree

const uint32_t Burger::MemoryManagerHandle::kMemoryIDFree = UINT32_MAX - 1
static

Free handle memory ID.

◆ kMemoryIDReserved

const uint32_t Burger::MemoryManagerHandle::kMemoryIDReserved = UINT32_MAX
static

Reserved handle memory ID.

◆ kMemoryIDUnused

const uint32_t Burger::MemoryManagerHandle::kMemoryIDUnused = UINT32_MAX - 2
static

Unused handle memory ID.

◆ kSystemMemoryChuckSize

const uintptr_t Burger::MemoryManagerHandle::kSystemMemoryChuckSize = 0x1000000
static

Default memory chunk allocation size from system.

◆ kSystemMemoryReservedSize

const uintptr_t Burger::MemoryManagerHandle::kSystemMemoryReservedSize = 0x40000
static

Default reserved system memory size.

◆ m_FreeMemoryChunks

Handle_t Burger::MemoryManagerHandle::m_FreeMemoryChunks
private

Free handle list.

◆ m_HighestUsedMemory

Handle_t Burger::MemoryManagerHandle::m_HighestUsedMemory
private

Last used memory handle (End of linked list)

◆ m_Lock

Mutex Burger::MemoryManagerHandle::m_Lock
private

Lock for multi-threading support.

◆ m_LowestUsedMemory

Handle_t Burger::MemoryManagerHandle::m_LowestUsedMemory
private

First used memory handle (Start of linked list)

◆ m_MemPurgeCallBack

MemPurgeProc Burger::MemoryManagerHandle::m_MemPurgeCallBack
private

Callback before memory purging.

◆ m_pFreeHandle

Handle_t* Burger::MemoryManagerHandle::m_pFreeHandle
private

Pointer to the free handle list.

◆ m_pMemPurge

void* Burger::MemoryManagerHandle::m_pMemPurge
private

User pointer for memory purge.

◆ m_pSystemMemoryBlocks

SystemBlock_t* Burger::MemoryManagerHandle::m_pSystemMemoryBlocks
private

Linked list of memory blocks taken from the system.

◆ m_PurgeHandleFiFo

Handle_t Burger::MemoryManagerHandle::m_PurgeHandleFiFo
private

Purged handle linked list.

◆ m_PurgeHands

Handle_t Burger::MemoryManagerHandle::m_PurgeHands
private

Purged handle list.

◆ m_uTotalAllocatedMemory

uintptr_t Burger::MemoryManagerHandle::m_uTotalAllocatedMemory
private

All of the memory currently allocated.

◆ m_uTotalHandleCount

uint_t Burger::MemoryManagerHandle::m_uTotalHandleCount
private

Number of handles allocated.

◆ m_uTotalSystemMemory

uintptr_t Burger::MemoryManagerHandle::m_uTotalSystemMemory
private

Total allocated system memory.