Q: How can I track down these pesky malloc problems?
A: A number of debugging packages exist to help track down malloc problems; one popular one is Conor P. Cahill's ``dbmalloc'', posted to comp.sources.misc in 1992, volume 32. Others are ``leak'', available in volume 27 of the comp.sources.unix archives; JMalloc.c and JMalloc.h in the ``Snippets'' collection; MEMDEBUG from ftp.crpht.lu in pub/sources/memdebug ; and Electric Fence. See also question 18.16.
A number of commercial debugging tools exist, and can be invaluable in tracking down malloc-related and other stubborn problems: