4 ms·
IMHO one of the nicest things about tcmalloc isn't the performance it's the profiling. It samples your allocations and records the stack trace where an object
by thrownaway2424 12y ago
IMHO one of the nicest things about tcmalloc isn't the performance it's the profiling. It samples your allocations and records the stack trace where an object was allocated, and records that information over the life of your process. This can be invaluable when tracking leaks or performance problems suspected to be due to excessive new and delete.
http://gperftools.googlecode.com/svn/trunk/doc/heapprofile.html http://gperftools.googlecode.com/svn/trunk/doc/heapprofile.h...
- jpfr 12y agoHave you tried valgrind for this?
- thrownaway2424 12y agoYes and my experience is that valgrind is a tremendously slow way to do one-off debugging of a suspected memory leak. The instrumentation in tcmalloc is really different as it has almost no cost (depending on the size of the system you might want to adjust the sample parameter for highly multithreaded programs) and is running at all times so you can use it to troubleshoot in production. When I've used valgrind the program was so slow it wasn't the kind of thing you could put under a live workload.
- jpfr 12y agoTrue. Valgrind slows things considerably. In the end, what to use is a matter of workflow and convenience. Good to know how tcmalloc makes debugging memleaks easier. Just for for completeness, a third option would be a tracing tool that hooks into the kernel syscalls (e.g. the lttng project). They have nearly zero performance penalty as well.