have a look at memprof, debauch and checker by GNU. With memprof and debauch one doesnt even need to recompile, it can trace both the parent and child's memory profile if the code has a fork + works for threads also. Moreover memprof has a graphical interface through gnome libraries sreangsu