0

所以我试图在 Ubuntu 18 中查看我的 c++ 程序的堆内存使用情况

我使用以下方法运行它:

valgrind --tool=massif --smc-check=all ./myprogram

我得到了相当大的输出,这没关系。我使用 massif-visualizer 查看它。

我得到一个漂亮的图表和所有这些。但我想在我的程序结束时详细查看它的关闭情况。但我似乎无法放大图表视图,而且我看不到这样做的选项。

手册页(这里)是这样说的:

Massif 会生成一些详细的快照,这些快照基本上构成了树。如果您想以比简单树视图更舒适的方式获得概览,请切换到详细快照选项卡并查看可视化为调用图的树。放大、缩小、使用鸟瞰图并查看对给定快照有何贡献。请注意,具有相同内存成本的函数调用被分组以轻松找到有趣的部分。

但我看不到“ switch over to the detailed snapshot tab”的选项......还有其他人知道该怎么做吗?

Ubuntu 18

地块可视化器 0.7

4

1 回答 1

1

代替 massif 可视化器,您可以使用 kcachegrind 使用 valgrind 3.13 中出现的新“xtree 功能”来可视化内存。

这是 valgrind --help 的摘录:

  user options for Valgrind tools that replace malloc:
    --alignment=<number>      set minimum alignment of heap allocations [16]
    --redzone-size=<number>   set minimum size of redzones added before/after
                              heap blocks (in bytes). [16]
    --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]

有关详细信息,请参阅http://www.valgrind.org/docs/manual/manual-core.html#manual-core.xtree

于 2018-07-31T21:31:17.230 回答