c++memory-managementvalgrindmemory-profilingmassif

Heap deallocation profiling


valgrind's massif tool is able to give me points in my code (including call stacks) where data is allocated.

E.g.

99.97% (3,775,782,255B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
->51.05% (1,928,081,040B) 0x37E712: MyFunc() (my_file.h:49)
| ->51.05% (1,928,081,040B) 0x37E15A: AnotherFunc() (my_file.cpp:213)
...

Instead of getting these statistics for malloc/new, is it possible to get it for free/delete instead?

I.e. is tracking deallocations possible?


Solution

  • You can track deallocation using e.g. memcheck and the option --xtree-memory=full.

    See e.g. https://www.valgrind.org/docs/manual/manual-core.html#opt.xtree-memory and https://www.valgrind.org/docs/manual/manual-core.html#manual-core.xtree for more information.