簡體   English   中英

valgrind可以報告丟失塊的內存地址(用於調試遞歸函數調用)嗎?

[英]Can valgrind report a memory address of a lost block (for debugging recursive function calls)?

這個問題與我的問題最相似,但是它已經很老了,所以我想知道此后是否有任何變化。

我的valgrind輸出為:

==29443== 109 (16 direct, 93 indirect) bytes in 2 blocks are definitely lost in loss record 270 of 309
==29443==    at 0x4C2B0E0: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==29443==    by 0x4F4E8DB: grl::Configuration::Configuration(grl::Configuration const&) (configuration.h:192)
==29443==    by 0x4F49973: grl::YAMLConfigurator::load(YAML::Node const&, grl::Configuration*, std::string const&) (configurable.cpp:74)
==29443==    by 0x4F499FC: grl::YAMLConfigurator::load(YAML::Node const&, grl::Configuration*, std::string const&) (configurable.cpp:75)
==29443==    by 0x4F499FC: grl::YAMLConfigurator::load(YAML::Node const&, grl::Configuration*, std::string const&) (configurable.cpp:75)
==29443==    by 0x4F499FC: grl::YAMLConfigurator::load(YAML::Node const&, grl::Configuration*, std::string const&) (configurable.cpp:75)
==29443==    by 0x40C78E: grl::YAMLConfigurator::load(std::string, grl::Configuration*, std::string const&) (configurable.h:321)
==29443==    by 0x40B897: main (deployer.cpp:180)

程序在開始時通過遞歸調用從yaml文件讀取並將所有必需的參數作為對(name, allocated address)存儲在映射中進行(name, allocated address) 我可以打印這些對。 因此,如果valgrind可以告訴我一個丟失值的地址,那么我可以得到一個參數名稱,並檢查為什么不釋放它。

如果無法使用該功能,我還能使用什么?

您可以使用vgdb在valgrind + gdb下運行程序。 參見http://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.gdbserver

然后,您可以使用各種valgrind memcheck監視器命令進行泄漏搜索,並獲取泄漏塊的地址/大小。 參見http://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM