mercredi 2 mars 2016

Valgrind - Automated memory leak report with histogram

I'm currently testing a simple command-line application with Valgrind where I am tracking down an obscure memory leak.

Is it possible to setup Valgrind to profile an application, and:

  • Just log memory leaks to a file.
  • Automatically exit when the program is complete.
  • Provide a histogram analysis of outstanding mallocs (ie: show the size of all non-freed/leaked memory, and summing up how many mallocs of the same size are outstanding. This would let me know if data buffers (1MB each) aren't being freed, versus image buffers (16MB) each are leaking).
  • What malloc()/calloc()/strdup() call in my source code generated the memory that hasn't yet been freed?

The first two requirements seem very possible. I'm not sure if the third feature is available in Valgrind. I've seen it in tools like QNX Momentics. As for the fourth, I don't know if Valgrind is able to do source-file integration like GDB in order to map source code to memory allocation calls.

Is such an automated task possible?

Thanks!

Aucun commentaire:

Enregistrer un commentaire