HeapStats Class ReferenceA module for detecting and finding memory leaks.
More...
#include <HeapStats.h>
List of all members.
|
Static Public Member Functions |
| static void | start () |
| | Start collecting statistics.
|
| static void | stop () |
| | Stop collecting statistics.
|
| static void | start_news () |
| | Start collecting "new" statistics.
|
| static void | start_dels () |
| | Start collecting delete statistics.
|
| static void | stop_news () |
| | Stop collecting "new" statistics.
|
| static void | stop_dels () |
| | Stop collecting delete statistics.
|
| static void | restart () |
| | Start collecting statistics again.
|
| static void | report (ostream &o=cout) |
| | Print out number of new\'s and delete\'s.
|
| static void | reset (void) |
| | Reset the counters.
|
| static int | memory_leak (void) |
| | Return TRUE if number of new\'s do not match number of delete\'s.
|
| static void | print_memory_leaks (ostream &o=cout) |
| | Print all memory leaks that has been detected.
|
Friends |
| void * | operator new (unsigned int) throw (std::bad_alloc) |
| | < friend void* operator new(size_t);
|
| void | operator delete (void *) throw () |
| | friend void remember_memory( void *ptr, size_t size );
|
| void | remember_memory (void *ptr, unsigned int size) |
| | friend void* recall_memory( size_t size );
|
| void * | recall_memory (unsigned int size) |
| | void * recall_memory( size_t size );
|
Detailed Description
A module for detecting and finding memory leaks.
Polaris Base - See also:
- HeapStats.h
HeapStats.h
HeapStats.cc
This module keeps tracks of the number of new\'s and delete\'s a program has generated. The module also keeps track of the addresses of objects that have been allocated but not deleted. This module is primarily used for spotting memory leaks.
The tracking the number of new\'s and delete\`s in a program can be started and stopped by the functions HeapStats::start() and HeapStats::stop(). These numbers can be printed out by the HeapStats::report() function. They can also be set back to zero by the HeapStats::reset() function.
In addition to keeping track of the numbers of new\`s and delete\`s in a program, HeapStats also keeps track of the addresses and sizes of objects that have been allocated but not deleted. The function HeapStats::print_memory_leaks() can be used to print out these undeleted objects. Like the tracking of the numbers of new\`s and delete\`s, the collection of these statistics is controlled by the start(), stop(), and reset() functions.
Definition at line 62 of file HeapStats.h.
Member Function Documentation
| void HeapStats::start |
( |
|
) |
[static] |
|
|
|
Start collecting statistics.
Definition at line 75 of file HeapStats.cc. |
| void HeapStats::stop |
( |
|
) |
[static] |
|
| void HeapStats::start_news |
( |
|
) |
[static] |
|
|
|
Start collecting "new" statistics.
Definition at line 82 of file HeapStats.cc. |
| void HeapStats::start_dels |
( |
|
) |
[static] |
|
|
|
Start collecting delete statistics.
Definition at line 88 of file HeapStats.cc. |
| void HeapStats::stop_news |
( |
|
) |
[static] |
|
|
|
Stop collecting "new" statistics.
Definition at line 56 of file HeapStats.cc. |
| void HeapStats::stop_dels |
( |
|
) |
[static] |
|
|
|
Stop collecting delete statistics.
Definition at line 62 of file HeapStats.cc. |
| void HeapStats::restart |
( |
|
) |
[static] |
|
| void HeapStats::report |
( |
ostream & |
o = cout |
) |
[static] |
|
| void HeapStats::reset |
( |
void |
|
) |
[static] |
|
| int HeapStats::memory_leak |
( |
void |
|
) |
[static] |
|
|
|
Return TRUE if number of new\'s do not match number of delete\'s.
Definition at line 113 of file HeapStats.cc. |
| void HeapStats::print_memory_leaks |
( |
ostream & |
o = cout |
) |
[static] |
|
|
|
Print all memory leaks that has been detected.
Definition at line 119 of file HeapStats.cc.
References BaseMapRoot::entries(), ProtoMap< S, T >::find_ref(), Listable::fingerprint_ok(), TypedBaseMap< S, T >::first_ref(), HeapElem::ptr, HeapElem::size, and TypedBaseMap< S, T >::successor_ref().
Referenced by main(), and test_expr_str(). |
Friends And Related Function Documentation
| void* operator new |
( |
unsigned int |
sz |
) |
throw (std::bad_alloc) [friend] |
|
| void operator delete |
( |
void * |
p |
) |
throw () [friend] |
|
| void remember_memory |
( |
void * |
ptr, |
|
|
unsigned int |
size |
|
) |
[friend] |
|
|
|
friend void* recall_memory( size_t size );
Definition at line 114 of file mem_manager.cc. |
| void* recall_memory |
( |
unsigned int |
size |
) |
[friend] |
|
The documentation for this class was generated from the following files:
|