2
// mld.h,v 1.7 2003/11/09 20:44:19 dhinton Exp
7
#include "ace/config-all.h"
9
#if !defined (ACE_LACKS_PRAGMA_ONCE)
11
#endif /* ACE_LACKS_PRAGMA_ONCE */
13
#include "ace/Singleton.h"
14
#include "ace/Atomic_Op.h"
15
#include "ace/Mutex.h"
18
This is a cheap memory leak detector. Each class I want to watch over
19
contains an mld object. The mld object's ctor increments a global counter
20
while the dtor decrements it. If the counter is non-zero when the program
21
is ready to exit then there may be a leak.
30
static int value (void);
33
static ACE_Atomic_Op < ACE_Mutex, int >counter_;
36
// ================================================
39
Just drop 'MLD' anywhere in your class definition to get cheap memory leak
40
detection for your class.
45
Use 'MLD_COUNTER' in main() to see if things are OK.
47
#define MLD_COUNTER mld::value()
49
// ================================================