Reputation: 1015
I record memory allocations using valgrind massif and use ms_print to create a document of snapshots that shows me which callstack holds how much memory currently, right?
I want to measure which callstacks have allocated most over the whole program run, that means deallocated memory should be taken into account when calculating the weight of a callstack.
Is this possible?
Regards
Upvotes: 1
Views: 929
Reputation: 3807
When a tool (such as memcheck, massif, ...) replaces the memory allocation functions (malloc, free, ...), then valgrind provides the option:
--xtree-memory=none|allocs|full profile heap memory in an xtree [none]
and produces a report at the end of the execution
none: no profiling, allocs: current allocated
size/blocks, full: profile current and cumulative
allocated size/blocks and freed size/blocks.
--xtree-memory-file=<file> xtree memory report file [xtmemory.kcg.%p]
So, if you use --xtree-memory=full, you will get a file that you can visualise with kcachegrind. The resulting file details a.o. what is currently allocated, and what was allocated and then freed.
See http://www.valgrind.org/docs/manual/manual-core.html#manual-core.xtree for more details.
Upvotes: 2