MADNESS  0.10.1
Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | List of all members
madness::WorldMemInfo Class Reference

Used to output memory statistics and control tracing, etc. More...

#include <worldmem.h>

Public Member Functions

void print () const
 Prints memory use statistics to std::cout. More...
 
void reset ()
 Resets all counters to zero. More...
 
void set_max_mem_limit (unsigned long max_mem_limit)
 Set the maximum memory limit (trying to allocate more will throw MadnessException) More...
 
void set_trace (bool trace)
 If trace is set true a message is printed for every new and delete. More...
 

Public Attributes

unsigned long cur_num_bytes
 Current amount of allocated memory in bytes. More...
 
unsigned long cur_num_frags
 Current number of allocated fragments. More...
 
unsigned long max_mem_limit
 if size+cur_num_bytes>max_mem_limit new will throw MadnessException More...
 
unsigned long max_num_bytes
 Lifetime maximum number of allocated bytes. More...
 
unsigned long max_num_frags
 Lifetime maximum number of allocated fragments. More...
 
unsigned long num_del_calls
 Counts calls to delete. More...
 
unsigned long num_new_calls
 If you add new stats be sure that the initialization in worldmem.cc is OK. More...
 
bool trace
 

Static Public Attributes

static const unsigned long overhead = 4*sizeof(long) + 16
 

Private Member Functions

void do_del (void *p, std::size_t size)
 Invoked when user pointer p is deleted with size bytes. More...
 
void do_new (void *p, std::size_t size)
 Invoked when user pointer p is allocated with size bytes. More...
 

Detailed Description

Used to output memory statistics and control tracing, etc.

There is currently only one instance of this class in worldmem.cc that is used by special versions of global new+delete enabled by compiling with WORLD_GATHER_MEM_STATS enabled.

Default for max_mem_limit is unlimited.

Member Function Documentation

◆ do_del()

void madness::WorldMemInfo::do_del ( void *  p,
std::size_t  size 
)
private

Invoked when user pointer p is deleted with size bytes.

References cur_num_bytes, cur_num_frags, num_del_calls, p(), and trace.

◆ do_new()

void madness::WorldMemInfo::do_new ( void *  p,
std::size_t  size 
)
private

Invoked when user pointer p is allocated with size bytes.

References cur_num_bytes, cur_num_frags, max_num_bytes, max_num_frags, num_new_calls, p(), and trace.

◆ print()

void madness::WorldMemInfo::print ( ) const

Prints memory use statistics to std::cout.

References cur_num_bytes, cur_num_frags, max_num_bytes, max_num_frags, num_del_calls, num_new_calls, and overhead.

Referenced by madness::print_stats().

◆ reset()

void madness::WorldMemInfo::reset ( )

Resets all counters to zero.

References cur_num_bytes, cur_num_frags, max_num_bytes, max_num_frags, num_del_calls, and num_new_calls.

◆ set_max_mem_limit()

void madness::WorldMemInfo::set_max_mem_limit ( unsigned long  max_mem_limit)
inline

Set the maximum memory limit (trying to allocate more will throw MadnessException)

References max_mem_limit.

◆ set_trace()

void madness::WorldMemInfo::set_trace ( bool  trace)
inline

If trace is set true a message is printed for every new and delete.

References trace.

Member Data Documentation

◆ cur_num_bytes

unsigned long madness::WorldMemInfo::cur_num_bytes

Current amount of allocated memory in bytes.

Referenced by do_del(), do_new(), print(), and reset().

◆ cur_num_frags

unsigned long madness::WorldMemInfo::cur_num_frags

Current number of allocated fragments.

Referenced by do_del(), do_new(), print(), and reset().

◆ max_mem_limit

unsigned long madness::WorldMemInfo::max_mem_limit

if size+cur_num_bytes>max_mem_limit new will throw MadnessException

Referenced by set_max_mem_limit().

◆ max_num_bytes

unsigned long madness::WorldMemInfo::max_num_bytes

Lifetime maximum number of allocated bytes.

Referenced by do_new(), print(), and reset().

◆ max_num_frags

unsigned long madness::WorldMemInfo::max_num_frags

Lifetime maximum number of allocated fragments.

Referenced by do_new(), print(), and reset().

◆ num_del_calls

unsigned long madness::WorldMemInfo::num_del_calls

Counts calls to delete.

Referenced by do_del(), print(), and reset().

◆ num_new_calls

unsigned long madness::WorldMemInfo::num_new_calls

If you add new stats be sure that the initialization in worldmem.cc is OK.

Counts calls to new

Referenced by do_new(), print(), and reset().

◆ overhead

const unsigned long madness::WorldMemInfo::overhead = 4*sizeof(long) + 16
static

Referenced by print().

◆ trace

bool madness::WorldMemInfo::trace

Referenced by do_del(), do_new(), and set_trace().


The documentation for this class was generated from the following files: