我使用valgrind massif记录内存分配,并使用ms_print创建一个快照文档,该文档显示哪个调用栈当前拥有多少内存,对吧?
我想衡量哪些调用栈在整个程序运行中分配的最多,这意味着在计算调用栈的权重时,应该考虑释放的内存。
这个是可能的吗?
问候
发布于 2020-02-15 22:08:21
当一个工具(如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可视化的文件。生成的文件详细说明了a.o.当前分配了什么,以及分配了什么,然后释放了什么。
有关更多详细信息,请参阅http://www.valgrind.org/docs/manual/manual-core.html#manual-core.xtree。
https://stackoverflow.com/questions/60171507
复制相似问题