xmemory features a single debug level:
/** This symbol sets the debug level for the xmemory module. Debug levels are defined as follows: 0 no debugging. 1 add tracing capabilities for memory leak detection 2 add diagnostics in xmemory_status 3 add debug messages */ #ifndef XMEMORY_DEBUG #define XMEMORY_DEBUG 0 #endif
As mentioned in the doc, most users will want to compile the module without defining the XMEMORY_DEBUG symbol in the Makefile (through the -D preprocessor option) which will reduce the size of the global allocation table.
If you suspect you have memory leaks, it is a good idea to switch the debug level to 1, which will help you by reporting for each allocated block the kind of memory that was allocated (real, virtual, or mapped file), and most importantly the name of the file and line number where the allocation took place.
Setting the debug level to 2 will change the behaviour of xmemory_status(), which will then systematically print out diagnostics about your memory use, in addition to the potential memory status.
A debug level of 3 and above will activate debug messages informing you whenever an allocation or deallocation takes place, about the internal working of the module, etc. It is not recommended to activate such a debug level unless you want to debug the xmemory module itself.
The above definition of XMEMORY_DEBUG allows to change the value at compile-time without modifying the xmemory source code. Example:
Compile without debug: % cc -c xmemory.c % Compile with highest debug level: % cc -c xmemory.c -DXMEMORY_DEBUG=3