|
The run-time memory usage statistics are automatically gathered by the delivered system with the auditing runtime configuration argument set to
TRUE. The data is collected into the following structure and can be retrieved with a call to
mmgr_debug_stats as the following code snippet shows.
|
|
|
struct mmgr_statistics {
|
|
|
size_t high_bytes;
|
|
// the high water mark
|
|
size_t alloc_bytes;
|
|
// total bytes allocated
|
|
size_t alloc_calls;
|
|
// number of allocation calls
|
|
size_t free_bytes;
|
|
// total bytes freed
|
|
size_t free_calls;
|
|
// number of free calls
|
|
size_t size_array[257];
|
// most frequent allocations sizes
|
|
size_t double_deletes;
|
|
// non-audited address delete count
|
|
size_t mismatched_callers;
|
// array allocation -
|
|
|
|
|
|
|
|
|
// non array delete for example
|
|
size_t mismatched_sizes;
|
// allocated as a foo - deleted as a bar
|
|
|
mutex_resource mmgr_statistics_mutex;
|
|
};
|
|
|
Application programmers can also set a breakpoint in
mmgr_debug to intercept calls to the memory manager and look at these statistics at run time. They can also edit the
mmgr_debug function to insert their own statistics handling code.
|
|
|
If the memory manager is built with the
MMGR_AUDIT_LEAKS compiler directive defined, the gathered statistics are also dumped to the
mmgr.log file upon program termination.
|