FXMemDbg.h File Reference


Detailed Description

Redefines the memory allocation routines.

Most libraries don't bother with trapping memory leaks - not so with TnFOX! Of course this is no substitute for valgrind on Linux, but it's good enough to catch most leaks.

Usage:

If you wish to trap memory leaks, include this code after all other include's in your C++ file but before the main body:

#include <FXMemDbg.h>
#if defined(DEBUG) && !defined(FXMEMDBG_DISABLE)
static const char *_fxmemdbg_current_file_ = __FILE__;
#endif
In debug mode only, before your program quits, you'll get a list of all unfreed memory blocks and where they were allocated if the allocation occurred within a file covered by the code declaration above.

If you need to undo the allocator macro definitions, simply wrap the relevant code with include <FXMemDbg.h> e.g.

#include <FXMemDbg.h>
#if defined(DEBUG) && !defined(FXMEMDBG_DISABLE)
static const char *_fxmemdbg_current_file_ = __FILE__;
#endif
... redefinitions are turned on ...
#include <FXMemDbg.h>
 Redefinitions are now turned off
obj = new(heap, 32) AlignedObject;
#include <FXMemDbg.h>
 Redefinitions are now turned on again
FXMemDbg.h is a pure C preprocessor file and hence can be included anywhere safely.

Note:
If you wish to disable this facility, define FXMEMDBG_DISABLE. Note that it is disabled when compiled as release anyway.

Definition in file FXMemDbg.h.

Go to the source code of this file.


(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:31 2009 for TnFOX by doxygen v1.4.7