Finding mem leaks with mtrace() on glibc-based systems



The mtrace() call and respective utility in glibc seems to handy
for tracking leaks whenever GNU_SOURCE is defined.

Quick usage:

#include <mcheck.h> and then call mtrace() at the start of func()
and muntrace() before it returns.

Compile the program with -g for debugging, and set the environment
variable MALLOC_TRACE to a file to log mem allocation and freeing.
Once you have run your program, run mtrace <program> $MALLOC_TRACE

It isn't utilized in GNOME sources AFAIS, why not?

  http://cvs.gnome.org/lxr/ident?i=mtrace

-- Ole




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]