blob: 82a83515121ec1050620305ed1f228a2245bff1c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// $Id$
#ifndef MLD_H
#define MLD_H
#include "ace/Synch.h"
#include "ace/Singleton.h"
/*
This is a cheap memory leak detector. Each class I want to watch
over contains an mld object. The mld object's ctor increments a
global counter while the dtor decrements it. If the counter is
non-zero when the program is ready to exit then there may be a leak.
*/
class mld
{
public:
mld(void);
~mld(void);
static int value(void);
protected:
static ACE_Atomic_Op<ACE_Mutex,int> counter_;
};
//================================================
/*
Just drop 'MLD' anywhere in your class definition to get cheap
memory leak detection for your class.
*/
#define MLD mld mld_
/*
Use 'MLD_COUNTER' in main() to see if things are OK.
*/
#define MLD_COUNTER mld::value()
//================================================
#endif
|