casacore::MemoryTrace Class Reference

memory usage tracing mechanism More...

#include <MemoryTrace.h>

List of all members.

Static Public Member Functions

static void start ()
 Start the tracing.
static void stop ()
 Stop the tracing.
static void open ()
 Open the trace file if not open yet.
static void close ()
 Close the tracing output file.
static Bool isOn ()
 Is tracing on?
static Bool isOpen ()
 Is the tracing file opened?
static void writeBlock (const char *msg, const std::string &name)
 Write a block line in the output file.
static void writeBlock (const char *msg, const char *name)
static std::ofstream & writeAlloc (const void *ptr, size_t)
 Write an alloc or free message.
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.
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.

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 *)

Detailed Description

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:

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.


Member Function Documentation

static void casacore::MemoryTrace::close (  )  [static]

Close the tracing output file.

static void casacore::MemoryTrace::freeHook ( void *  ,
const void *  caller 
) [static]
static Bool casacore::MemoryTrace::isOn (  )  [inline, static]

Is tracing on?

Definition at line 89 of file MemoryTrace.h.

References theirDoTrace.

static Bool casacore::MemoryTrace::isOpen (  )  [inline, static]

Is the tracing file opened?

Definition at line 93 of file MemoryTrace.h.

References theirFile.

static std::string casacore::MemoryTrace::makeString ( const char *   )  [static]

Make a string from a char* without tracing a possible malloc in the string constructor.

static void* casacore::MemoryTrace::mallocHook ( size_t  ,
const void *  caller 
) [static]

The hooks for malloc and free writing the trace messages.

static void casacore::MemoryTrace::open (  )  [static]

Open the trace file if not open yet.

static void casacore::MemoryTrace::start (  )  [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 void casacore::MemoryTrace::stop (  )  [static]

Stop the tracing.

static std::ofstream& casacore::MemoryTrace::writeAlloc ( const void *  ptr,
size_t   
) [static]

Write an alloc or free message.

static void casacore::MemoryTrace::writeBlock ( const char *  msg,
const char *  name 
) [static]
static void casacore::MemoryTrace::writeBlock ( const char *  msg,
const std::string &  name 
) [static]

Write a block line in the output file.

static std::ofstream& casacore::MemoryTrace::writeFree ( const void *  ptr  )  [static]

Member Data Documentation

Definition at line 113 of file MemoryTrace.h.

Referenced by isOn().

std::ofstream casacore::MemoryTrace::theirFile [static, private]

Definition at line 114 of file MemoryTrace.h.

Referenced by isOpen().

void(* casacore::MemoryTrace::theirOldFreeHook)(void *, const void *) [static, private]
void*(* casacore::MemoryTrace::theirOldMallocHook)(size_t, const void *) [static, private]

Definition at line 115 of file MemoryTrace.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1