【问题标题】:Valgrind massif - measure total memory allocations per callstackValgrind massif - 测量每个调用堆栈的总内存分配
【发布时间】:2020-05-27 00:24:54
【问题描述】:

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

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

这可能吗?

问候

【问题讨论】:

    标签: valgrind massif


    【解决方案1】:

    当一个工具(如 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 了解更多详情。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 2017-01-04
      • 2018-02-03
      • 2018-07-24
      • 2015-09-08
      • 2011-05-28
      相关资源
      最近更新 更多