libbbb - memtrack


Provides the means to track memory usage across classes. The components are only inserted in code if BB_MEMTRACK is defined, otherwise everything vanishes. Thus, BB_MEMTRACK is perfect for being defined when DEBUG or other macro is defined (or undefined, like QT_NO_DEBUG).

The user then inherits the classes to be tracked from MemTrack and used the BBM_TRACK macro to identify the class.

1 class MemTrackTest : public MemTrack    {
2     BBM_TRACK(MemTrackTest)
3 public:
4     MemTrackTest() : MemTrack() {}
5     ~MemTrackTest() {}
6 };

MemTrackMng provides the means to track and querry the state of the memory. It may be a good idea to add this pice of code at the end of the program, just before it exists:

1 #ifndef QT_NO_DEBUG
2 MemTrackMng::dump();
3 #endif

It will print all instances that were not released, yet.


Related source code documentation: MemTrack, MemTrackMng