MemCheck Deluxe 1.2.2 review

Download
by rbytes.net on

MemCheckDeluxe is an enhanced leak finder/memory profiler

License: BSD License
File size: 15K
Developer: Dakoda
0 stars award from rbytes.net

MemCheckDeluxe is an enhanced leak finder/memory profiler. It tracks all the memory allocated, and can report where it was created at the end of a program (memory that would have been leaked).

It tracks the largest and smallest chunks allocated, the maximum memory used, and the highest number of allocations at any time. Some headway has been made to allow C++'s allocation operators new and delete to be tracked.

Usage

To use it, #define _MCD_CHECK, include mcd.h, and add mcd.c to the list of source files to build in your project. then, call 'showMemStats()' at any time to see the currently outstanding allocations and usage stats.

If you don't define _MCD_CHECK, it compiles away, improving performance. It is probably not a good idea to have some parts of a library use mcd, and not others. Pointers created in non-mcd parts won't be tracked and may confuse mcd, and stuff made in mcd, and freed elsewhere won't be properly cleaned up internally, leading to false leaks.

When included, a warning is normally issued, informing the user that performance will be affected. If this gets annoying, define MCD_QUIET to make it go away.

When including mcd.h, be sure to make it the last file included, as it redefines some macros. including things after it, especially system headers (stdlib.h, etc) can cause some nasty error messages and it will fail to compile anything.

One can define MCD_VERBOSE to have each and every malloc, calloc, realloc, strdup, strndup, and free be written to the RealTime log, including the size, calling function, and line number. The RealTime log defaults to stderr, but can be set to any file you want with
_MCD_RealTimeLog(FILE*fp). Just make sure the file is opened for writing/appending, and all verbosity will go there instead.

Please note that if you want RealTime log output, you MUST define MCD_VERBOSE.

With default settings, free(NULL) will simply return, providing you with an error message in the RealTime log if verbose was enabled. If you are working with a C library that acts differently when free(null) happens, define MCD_FREE_NULL, and it will generate the log message, and then perform the native free.

Using this is probably seldom needed, and will probably lead to a crash when/if it happens, providing you with a nice coredump to analyze. Again, this only applies if your C library's free(null) does something other than simply return.

There is a new flag, _MCD_GONE, that will remove all MCD code from the end product. It 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. The savings from this are about 15-20k (4-5k stripped).

MemCheck Deluxe 1.2.2 keywords