Memory

Engine/source/platform/platformMemory.cpp

More...

Classes:

class

Red/Black Tree Node - used to store queues of free blocks.

Public Enumerations

enum
EFlag {
  FLAG_Debug 
  FLAG_Global 
  FLAG_Static 
}

Public Functions

void *
alloc(dsize_t size, bool array, const char * fileName, const U32 line)
checkPtr(void * ptr)

Trigger a breakpoint if ptr is not a valid heap pointer or if its memory guards have been destroyed (only if TORQUE_DEBUG_GUARD is enabled).

ConsoleFunctionGroupBegin(Memory , "Memory manager utility functions." )
countUnflaggedAllocs(const char * file, S32 * outUnflaggedRealloc, EFlag flag)
DefineEngineFunction(freeMemoryDump , void , () , "@brief Dumps some useful statistics regarding free <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">memory.\n\n</a>" "Dumps an analysis of \'free chunks\' of memory. " "Does not print how much memory is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">free.\n\n</a>" "@ingroup Debugging" )
dumpUnflaggedAllocs(const char * file, EFlag flag)
enableLogging(const char * fileName)

Dump info on all memory blocks that are still allocated.

free(void * mem, bool array)
getMemoryInfo(void * ptr, Info & info)
logDumpTraverse(MemDumpLog * sizes, TreeNode * header, U32 depth)
void *
realloc(void * mem, dsize_t size, const char * fileName, const U32 line)
setBreakAlloc(U32 breakAlloc)

Detailed Description

Public Enumerations

EFlag

Enumerator

FLAG_Debug
FLAG_Global
FLAG_Static

Public Variables

bool gAlwaysLogLeaks 
U32 gBlocksAllocated 
U32 gBreakAlloc 
U32 gBytesAllocated 
U32 gCurrAlloc 
bool gEnableLogging 
TreeNode * gFreeTreeRoot 
U32 gInsertCount 
char gLogFilename [256]
bool gNeverLogLeaks 
U32 gPageBytesAllocated 
PageRecord * gPageList 
U32 gRemoveCount 
TreeNode * gTreeFreeList 
TreeNode nil 
TreeNode * NIL 

Public Functions

alloc(dsize_t size, bool array, const char * fileName, const U32 line)

allocMemPage(dsize_t pageSize)

allocPage(dsize_t pageSize)

allocTreeNode()

checkPtr(void * ptr)

Trigger a breakpoint if ptr is not a valid heap pointer or if its memory guards have been destroyed (only if TORQUE_DEBUG_GUARD is enabled).

note:

This function does not allow interior pointers!

checkUnusedAlloc(FreeHeader * header, U32 size)

ConsoleFunctionGroupBegin(Memory , "Memory manager utility functions." )

ConsoleFunctionGroupEnd(Memory )

countUnflaggedAllocs(const char * file, S32 * outUnflaggedRealloc, EFlag flag)

DefineEngineFunction(freeMemoryDump , void , () , "@brief Dumps some useful statistics regarding free <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">memory.\n\n</a>" "Dumps an analysis of \'free chunks\' of memory. " "Does not print how much memory is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">free.\n\n</a>" "@ingroup Debugging" )

disableLogging()

dumpUnflaggedAllocs(const char * file, EFlag flag)

enableLogging(const char * fileName)

ensureAllFreed()

Dump info on all memory blocks that are still allocated.

note:

Only works if TORQUE_DISABLE_MEMORY_MANAGER is not defined; otherwise this is a NOP.

flagCurrentAllocs(EFlag flag)

free(void * mem, bool array)

freeTreeNode(TreeNode * tn)

getMemoryAllocated()

getMemoryInfo(void * ptr, Info & info)

getMemoryUsed()

logDumpTraverse(MemDumpLog * sizes, TreeNode * header, U32 depth)

memoryError()

realloc(void * mem, dsize_t size, const char * fileName, const U32 line)

rotateLeft(TreeNode * hdr)

rotateRight(TreeNode * hdr)

setBreakAlloc(U32 breakAlloc)

treeFindSmallestGreaterThan(dsize_t size)

treeInsert(FreeHeader * fhdr)

treeRemove(FreeHeader * hdr)

validate()

validateParentageRecurse(TreeNode * tree)

validateTree()

validateTreeRecurse(TreeNode * tree)