HDK
|
#include <SYS_Memory.h>
Public Member Functions | |
SYS_MemoryUser (const char *label) | |
SYS_MemoryUser (const SYS_MemoryUser &rhs) | |
const char * | getLabel () const |
size_t | getUsed () const |
size_t | getPeak () const |
void | inc (size_t amount) |
void | dec (size_t amount) |
void | setUsedPeak (size_t used, size_t peak) |
Forcibly set values - not typical usage, but required in some cases. More... | |
Memory Tracking
This class provides a mechanism for tracking memory usage. If all memory allocation and freeing is registered with this class, then the memory footprint and resource usage can be tracked.
There is a companion class at UT which allows for printing of the memory statistics.
An example of how to use this might be:
enum { MEM_DEBUG = 0, MEM_TASK1, MEM_TASK2, MEM_MAX_TASKS };
static SYS_MemoryUser theMemoryUsers[MEM_MAX_TASKS] = { SYS_MemoryUser("Debug), SYS_MemoryUser("Task One"), SYS_MemoryUser("Task Two"), };
static SYS_MemoryTable theMemoryTable(theMemoryUsers, sizeof(theMemoryUsers)/sizeof(SYS_MemoryTable));
int main(int argc, char *argv[]) { UT_WorkBuffer stats; void *mem; mem = SYS_Memory::Malloc(theMemoryTable, MEM_TASK1, 128); mem = SYS_Memory::Realloc(theMemoryTable, MEM_TASK1, mem, 128, 256); SYS_Memory::Free(theMemoryTable, MEM_TASK1, mem, 256); UT_Memory::printTable(stats, theMemoryTable); cout << stats.buffer(); return 0; }
Definition at line 62 of file SYS_Memory.h.
|
inline |
Definition at line 64 of file SYS_Memory.h.
|
inline |
Definition at line 72 of file SYS_Memory.h.
|
inline |
Definition at line 87 of file SYS_Memory.h.
|
inline |
Definition at line 79 of file SYS_Memory.h.
|
inline |
Definition at line 81 of file SYS_Memory.h.
|
inline |
Definition at line 80 of file SYS_Memory.h.
|
inline |
Definition at line 83 of file SYS_Memory.h.
|
inline |
Forcibly set values - not typical usage, but required in some cases.
Definition at line 93 of file SYS_Memory.h.