Go to the documentation of this file.
28 #ifndef CASA_MEMORYTRACE_H
29 #define CASA_MEMORYTRACE_H
31 #include <casacore/casa/aips.h>
32 #include <casacore/casa/OS/Timer.h>
97 static void writeBlock (
const char* msg,
const std::string& name);
98 static void writeBlock (
const char* msg,
const char* name);
101 static std::ofstream&
writeAlloc (
const void* ptr,
size_t);
102 static std::ofstream&
writeFree (
const void* ptr);
105 static void*
mallocHook (
size_t,
const void* caller);
106 static void freeHook (
void*,
const void* caller);
117 static void* (*theirOldMallocHook)(size_t,
const void*);
151 #define traceMemoryAlloc(ptr,size,msg) \
152 if (casacore::MemoryTrace::isOpen()) { \
153 casacore::MemoryTrace::writeAlloc (ptr, size) << msg << std::endl; \
155 #define traceMemoryFree(ptr,msg) \
156 if (casacore::MemoryTrace::isOpen()) { \
157 casacore::MemoryTrace::writeFree (ptr) << msg << std::endl; \
160 #define traceMemoryBlockBegin(name) \
161 if (casacore::MemoryTrace::isOpen()) { \
162 casacore::MemoryTrace::writeBlock(" begin ", name); \
164 #define traceMemoryBlockEnd(name) \
165 if (casacore::MemoryTrace::isOpen()) { \
166 casacore::MemoryTrace::writeBlock(" end ", name); \
static std::ofstream & writeFree(const void *ptr)
static std::string makeString(const char *)
Make a string from a char* without tracing a possible malloc in the string constructor.
Class to write begin and end block message.
static Bool isOn()
Is tracing on?
static void open()
Open the trace file if not open yet.
static void writeBlock(const char *msg, const std::string &name)
Write a block line in the output file.
memory usage tracing mechanism
static void start()
Start the tracing.
MemoryTraceBlock(const std::string &name)
The constructor writes a block begin message.
static void stop()
Stop the tracing.
static void * mallocHook(size_t, const void *caller)
The hooks for malloc and free writing the trace messages.
static Bool isOpen()
Is the tracing file opened?
this file contains all the compiler specific defines
static void close()
Close the tracing output file.
static std::ofstream theirFile
bool Bool
Define the standard types used by Casacore.
static void freeHook(void *, const void *caller)
measure the time it takes to execute parts of a program
static std::ofstream & writeAlloc(const void *ptr, size_t)
Write an alloc or free message.
static void(* theirOldFreeHook)(void *, const void *)
~MemoryTraceBlock()
The constructor writes a block end message.