首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Valgrind massif -测量每个调用堆栈的总内存分配

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

Stack Overflow用户
提问于 2020-02-11 22:47:13
回答 1查看 204关注 0票数 1

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

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

这个是可能的吗?

问候

EN

回答 1

Stack Overflow用户

发布于 2020-02-15 22:08:21

当一个工具(如memcheck,massif,...)替换内存分配函数(malloc,free,...),然后valgrind提供以下选项:

代码语言:javascript
复制
--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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60171507

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档