Valgrind 测量每个调用堆栈的总内存分配



我使用 valgrind 地块记录内存分配,并使用ms_print创建一个快照文档,向我显示哪个调用堆栈当前有多少内存,对吧?

我想测量哪些调用堆栈在整个程序运行中分配最多,这意味着在计算调用堆栈的权重时应考虑已释放的内存。

这可能吗?

问候

当一个工具(如memcheck,massif,...(取代内存分配函数(malloc,free,...(时,valgrind提供了以下选项:

--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]

所以,如果你使用 --xtree-memory=full,你会得到一个你可以用 kcachegrind 可视化的文件。 生成的文件详细说明了当前分配的内容,以及已分配然后释放的内容。

请参阅 http://www.valgrind.org/docs/manual/manual-core.html#manual-core.xtree 了解更多详情。

最新更新