On valgrind and tcmalloc

I already wrote about tcmalloc, and how it helped with memory fragmentation. This time had some experience with extended features – memory profiling and leak checker. With tcmalloc it is possible to get an overview as well as detailed reports of what areas of memory are allocated for what uses. Even more, it can detect and report any memory that leaked. Of course, valgrind does that too. With one slight difference:

  • valgrind slows down applications 20-40 times (my tests ran 4s instead of 14ms)
  • tcmalloc does not. Same 14ms.

I wrote some MySQL UDFs for profiling and heap checking management, so can extract per-thread single-test stuff. Will try to clean up and release. Would be shame not to.

2 thoughts on “On valgrind and tcmalloc”

  1. Hi,

    I’m experiencing a memory leak on a production mysql server (that I never managed to reproduce in the lab), and tried tcmalloc. Unfortunately my tests failed because the memory consumption of mysql+tcmalloc is growing really too fast (compared to the memory leak only) and finally the box OOM’ed.
    The thing is that I certainly don’t need to monitor the whole server but maybe only some sessions or a single thread.
    Will your UDF be helpful in my case?
    Or do you have any pointers/ideas to find memory leak on a running production server?

  2. Brice, actually – as that growth was really fast you could’ve isolated memory leak bug quite fast too :) Just look at the heap profiler data.

Comments are closed.

%d bloggers like this: