casacore
|
#include <MemoryTrace.h>
Static Public Member Functions | |
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... | |
Static Private Attributes | |
static Bool | theirDoTrace |
static std::ofstream | theirFile |
static Timer | theirTimer |
static void *(* | theirOldMallocHook )(size_t, const void *) |
static void(* | theirOldFreeHook )(void *, const void *) |
memory usage tracing mechanism
Public interface
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:
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.
|
static |
Close the tracing output file.
|
static |
|
inlinestatic |
|
inlinestatic |
|
static |
Make a string from a char* without tracing a possible malloc in the string constructor.
|
static |
The hooks for malloc and free writing the trace messages.
|
static |
Open the trace file if not open yet.
|
static |
Start the tracing.
Nothing is done if already started. On the first time, it opens the trace file. The name of the trace file can be given in the env.var. CASACORE_MEMORYTRACE. If undefined, the name casacore_memorytrace.log will be used.
|
static |
Stop the tracing.
|
static |
Write an alloc or free message.
|
static |
|
static |
Write a block line in the output file.
|
static |
|
staticprivate |
Definition at line 113 of file MemoryTrace.h.
Referenced by isOn().
|
staticprivate |
Definition at line 114 of file MemoryTrace.h.
Referenced by isOpen().
|
staticprivate |
Definition at line 118 of file MemoryTrace.h.
|
staticprivate |
Definition at line 117 of file MemoryTrace.h.
|
staticprivate |
Definition at line 115 of file MemoryTrace.h.