26#ifndef CASA_MEMORYTRACE_H
27#define CASA_MEMORYTRACE_H
29#include <casacore/casa/aips.h>
30#include <casacore/casa/OS/Timer.h>
96 static std::ofstream&
writeAlloc(
const void* ptr,
size_t);
112 static void* (*theirOldMallocHook)(size_t,
const void*);
144#define traceMemoryAlloc(ptr, size, msg) \
145 if (casacore::MemoryTrace::isOpen()) { \
146 casacore::MemoryTrace::writeAlloc(ptr, size) << msg << std::endl; \
148#define traceMemoryFree(ptr, msg) \
149 if (casacore::MemoryTrace::isOpen()) { \
150 casacore::MemoryTrace::writeFree(ptr) << msg << std::endl; \
153#define traceMemoryBlockBegin(name) \
154 if (casacore::MemoryTrace::isOpen()) { \
155 casacore::MemoryTrace::writeBlock(" begin ", name); \
157#define traceMemoryBlockEnd(name) \
158 if (casacore::MemoryTrace::isOpen()) { \
159 casacore::MemoryTrace::writeBlock(" end ", name); \
~MemoryTraceBlock()
The constructor writes a block end message.
MemoryTraceBlock(const char *name)
MemoryTraceBlock(const std::string &name)
The constructor writes a block begin message.
static void open()
Open the trace file if not open yet.
static Bool isOn()
Is tracing on?
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.
static std::ofstream theirFile
static Bool isOpen()
Is the tracing file opened?
static void(* theirOldFreeHook)(void *, const void *)
static std::ofstream & writeAlloc(const void *ptr, size_t)
Write an alloc or free message.
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 void * mallocHook(size_t, const void *caller)
The hooks for malloc and free writing the trace messages.
static void close()
Close the tracing output file.
static void freeHook(void *, const void *caller)
static void start()
Start the tracing.
static void stop()
Stop the tracing.
For temporary backward namespace compatibility, use casa as alias for casacore.
String name() const
Return the name of the field.
bool Bool
Define the standard types used by Casacore.