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 45 46 47 48 49 50
|
/*!
\defgroup group_markers Memory Allocation Markers: Memory Leak Checking
\ingroup book_allocations
*/
/*!
\page page_markers
\ingroup group_markers
<hr><h2>Detailed Description</h2>
Libcwd does a weak attempt to support debugging of memory leaks.
I hope to greatly improve this in the future.
It is possible to mark allocations that are done till that moment, and then later check for memory
leaks by expecting no other memory allocations than those that already existed before the mark.
This is done by creating a marker_ct object.
The check for memory leaks is done when the marker is removed again.
This can be done recursively.
A \em marker is created by passing it a description:
\code
#if CWDEBUG_MARKER
libcwd::marker_ct* marker = new libcwd::marker_ct("Description of the marker");
#endif
\endcode
Any allocation done \em after the creation of this marker will be reported as a <B>leak</B> at the moment the \em marker is deleted.
Markers are clearly visible in the Allocated memory Overview.
They are labeled MARKER (see also the <A HREF="group__group__overview.html#AMO_allocator">allocator type</A> table).
All memory that is allocated after a \em marker, is displayed indented and below that marker in the Allocated memory Overview.
Finally, it is possible to move specific memory blocks outside markers, so they will not cause a memory leak detection.
This is done with the function
\code
namespace libcwd {
void move_outside(marker_ct* marker, void const* ptr);
}
\endcode
which would move the memory allocation pointed to by \a ptr outside the test region of \a marker.
A complete example program with output is given here:
\include markers.cc
*/
|