MemCheck Deluxe tracks memory usage and finds leaks.
The software also tracks the largest and smallest chunks allocated, the maximum memory used, and the highest number of allocations at any time. Additionally, the software has been enhanced to allow the tracking of C++'s allocation operators new and delete.
To use the software, you can simply #define _MCD_CHECK, include mcd.h, and add mcd.c to the list of source files in your project. Once you have done this, you can call 'showMemStats()' at any time to see the currently outstanding allocations and usage stats. If you do not define _MCD_CHECK, the software will compile away, improving performance.
It is important to note that it is not recommended to have some parts of a library use MemCheckDeluxe, and not others. This can result in pointers created in non-MemCheckDeluxe parts not being tracked, which can lead to confusion with the software. Similarly, if something is made in MemCheckDeluxe and freed elsewhere, it may not be properly cleaned up internally, leading to false leaks.
When including mcd.h, make sure it is the last file included, as it redefines some macros. Including files after it, particularly system headers such as stdlib.h, can cause errors and result in the software failing to compile anything.
MemCheckDeluxe provides the option to define MCD_VERBOSE, which allows you to see each and every malloc, calloc, realloc, strdup, strndup, and free that are made in real-time, including their size, calling function, and line number. The RealTime log defaults to stderr but can be set to any file of your choice with _MCD_RealTimeLog(FILE *fp).
There is also a MCD_FREE_NULL flag that can be defined if you are working with a C library that behaves differently when free(NULL) is called. By defining this flag, the software will generate a log message and then perform the native free, providing you with an error message in the RealTime log if verbose was enabled.
Finally, if you want to remove all MemCheckDeluxe code from the end product, you can define the _MCD_GONE flag. This must be defined when compiling both mcd.c and any other file that includes mcd.h. Note that defining _MCD_CHECK has no effect when _MCD_GONE is defined, and the savings from doing so are about 15-20k (4-5k stripped).
Version 1.2.2: N/A