include the mcheck.h header file in all your .c files, and call mtrace as the first statement in main.
See also LD_DEBUG, MALLOC_CHECK_
2 pages link to mcheck:
lib/plugin/WlugLicense.php:99: Warning: Invalid argument supplied for foreach()
lib/plugin/WlugLicense.php:111: Warning: in_array() [<a href='function.in-array'>function.in-array</a>]: Wrong datatype for second argument