如何分析Google性能工具中的heap_checker输出数据

问题描述 投票:-1回答:1

我们在应用程序中发生内存泄漏,需要修复。经过一番谷歌搜索,我偶然发现了Google性能工具(gperftools)。按照他们的文档,我将他们的heap_checker与重新加载的tc_malloc库一起使用。

我设法获得了一些输出,但不确定如何截取它。输出是这样的]

Have memory regions w/o callers: might report false leaks
Leak check _main_ detected leaks of 1372 bytes in 10 objects
The 10 largest leaks:
Using local file /usr/local/control/Control.
Leak of 988 bytes in 1 objects allocated from:
    @ 804f8ac _init
    @ 805237d _init
    @ b71c2a63 __libc_start_main
Leak of 128 bytes in 1 objects allocated from:
    @ 825c747 std::out_of_range::~out_of_range
    @ 804f8dc _init
    @ 805237d _init
    @ b71c2a63 __libc_start_main
Leak of 72 bytes in 1 objects allocated from:
    @ 825c3a2 std::out_of_range::~out_of_range
    @ 804f8dc _init
    @ 805237d _init
    @ b71c2a63 __libc_start_main
Leak of 72 bytes in 1 objects allocated from:
    @ 825c433 std::out_of_range::~out_of_range
    @ 804f8dc _init
    @ 805237d _init
    @ b71c2a63 __libc_start_main
Leak of 72 bytes in 1 objects allocated from:
    @ 825c4a7 std::out_of_range::~out_of_range
    @ 804f8dc _init
    @ 805237d _init
    @ b71c2a63 __libc_start_main
Leak of 16 bytes in 1 objects allocated from:
    @ 825c647 std::out_of_range::~out_of_range
    @ 804f8dc _init
    @ 805237d _init
    @ b71c2a63 __libc_start_main
Leak of 8 bytes in 1 objects allocated from:
    @ 825c5c7 std::out_of_range::~out_of_range
    @ 804f8dc _init
    @ 805237d _init
    @ b71c2a63 __libc_start_main
Leak of 8 bytes in 1 objects allocated from:
    @ 825c6b7 std::out_of_range::~out_of_range
    @ 804f8dc _init
    @ 805237d _init
    @ b71c2a63 __libc_start_main
...

我是不是诸如heap_profiling,heap_checking之类的工具的新手,并且不确定如何分析上述数据并找出泄漏的哪一部分。上面的代码在嵌入式板上运行了很短的时间(通常该程序应该运行几天),并且由于pprof --gv失败而没有任何显示。有什么方法可以使用远程系统以交互方式分析数据?

$ pprof /usr/local/control/Control "/tmp/Control.25866._main_-end.heap" --inuse_objects --lines --heapcheck  --edgefraction=1e-10 --nodefraction=1e-10 --text
Using local file /usr/local/control/Control.
Using local file /tmp/Control.25866._main_-end.heap.
Total: 10 objects
       9  90.0%  90.0%        9  90.0% std::out_of_range::~out_of_range ??:0
       1  10.0% 100.0%       10 100.0% _init ??:0
       0   0.0% 100.0%       10 100.0% __libc_start_main ??:0

非常感谢您的帮助。

谢谢。

c++ memory-leaks heap-memory gperftools google-perftools
1个回答
0
投票

经过几次反复试验。我在调试模式下(g ++ -g)编译了代码。通过在调试模式下编译代码,可以帮助我获取行号以及有关内存泄漏的更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.