|
HDK
|
#include <UT_MemoryTable.h>
Inheritance diagram for UT_MemoryUser:Public Member Functions | |
| UT_MemoryUser (const char *label, bool use_atomics=false) | |
| 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... | |
Additional Inherited Members | |
Protected Member Functions inherited from UT_NonCopyableNS::UT_NonCopyable | |
| UT_NonCopyable ()=default | |
| ~UT_NonCopyable ()=default | |
| UT_NonCopyable (const UT_NonCopyable &)=delete | |
| UT_NonCopyable & | operator= (const UT_NonCopyable &)=delete |
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 UT_MemoryUser theMemoryUsers[MEM_MAX_TASKS] = { UT_MemoryUser("Debug), UT_MemoryUser("Task One"), UT_MemoryUser("Task Two"), };
static UT_MemoryTable theMemoryTable(theMemoryUsers, sizeof(theMemoryUsers)/sizeof(UT_MemoryTable));
int main(int argc, char *argv[]) { UT_WorkBuffer stats; void *mem; mem = UT_Memory::Malloc(theMemoryTable, MEM_TASK1, 128); mem = UT_Memory::Realloc(theMemoryTable, MEM_TASK1, mem, 128, 256); UT_Memory::Free(theMemoryTable, MEM_TASK1, mem, 256); UT_Memory::printTable(stats, theMemoryTable); cout << stats.buffer(); return 0; }
Definition at line 64 of file UT_MemoryTable.h.
|
inline |
Definition at line 128 of file UT_MemoryTable.h.
|
inline |
Definition at line 143 of file UT_MemoryTable.h.
|
inline |
Definition at line 136 of file UT_MemoryTable.h.
|
inline |
Definition at line 141 of file UT_MemoryTable.h.
|
inline |
Note that getUsed() and getPeak() may not be thread-safe unless initialized with use_atomics = true
Definition at line 140 of file UT_MemoryTable.h.
|
inline |
Definition at line 142 of file UT_MemoryTable.h.
|
inline |
Forcibly set values - not typical usage, but required in some cases.
Definition at line 146 of file UT_MemoryTable.h.