|
static void | start () |
| Start the tracing. More...
|
|
static void | stop () |
| Stop the tracing. More...
|
|
static void | open () |
| Open the trace file if not open yet. More...
|
|
static void | close () |
| Close the tracing output file. More...
|
|
static Bool | isOn () |
| Is tracing on? More...
|
|
static Bool | isOpen () |
| Is the tracing file opened? More...
|
|
static void | writeBlock (const char *msg, const std::string &name) |
| Write a block line in the output file. More...
|
|
static void | writeBlock (const char *msg, const char *name) |
|
static std::ofstream & | writeAlloc (const void *ptr, size_t) |
| Write an alloc or free message. More...
|
|
static std::ofstream & | writeFree (const void *ptr) |
|
static void * | mallocHook (size_t, const void *caller) |
| The hooks for malloc and free writing the trace messages. More...
|
|
static void | freeHook (void *, const void *caller) |
|
static std::string | makeString (const char *) |
| Make a string from a char* without tracing a possible malloc in the string constructor. More...
|
|
memory usage tracing mechanism
Intended use:
Public interface
Review Status
- Reviewed By:
- UNKNOWN
- Date Reviewed:
- before2004/08/25
Synopsis
The MemoryTrace class provides some means to trace the memory usage of a program. It logs malloc and free messages in a file which can be examined by the python script memorytrace.py.
The tracing is done using hooks for malloc and free as explained in 'man malloc_hook'.
The tracing can be started and stopped at any time. On the first start the trace file is created. The file can be closed at any time, usually at the end of a program. Another start will recreate the file.
The trace file consists of 3 types of lines:
-
An allocation line like "a <address> <caller> <size>"
-
A deallocation line like "f <address> <caller>"
-
A line like "begin/end <name>" telling the script the beginning or end of a code block. It makes it possible to see how memory usage develops. Such lines can be inserted using the class MemoryTraceBlock.
All lines start with the number of milliseconds since the start of the program.
The script memorytrace.py can be used to interpret the log file and to show the memory usage.
Definition at line 70 of file MemoryTrace.h.