1.安装
sudo apt install valgrind # 如果找不到,先运行 sudo apt update
2.运行程序
//程序不带参数运行
valgrind --tool=memcheck --leak-check=full --log-file=/home/administrator/workspace/planning/mem_debug.txt ./output/bin/control
//程序带参数运行
valgrind --tool=memcheck --leak-check=full --log-file=/home/administrator/workspace/control/mem_debug.txt ./output/bin/control --control_conf_file=/home/administrator/workspace/control/output/conf/control/control_conf_RX.pb.txt --vehicle_config_path=/home/administrator/.airs/data/conf/RX-001/vehicle_param.pb.txt --control_calibration_file=/home/administrator/.airs/data/conf/RX-001/calibration_table.pb.txt
待程序启动后,检查终端中打印的调试信息,看是否出现”malloc
/new
“等类似的关键字,则相关信息一般都和内存分配有关,再结合代码仔细排查
3、程序结束
4. 参考文档
Using Valgrind to Find Memory Leaks - Cprogramming.com
Valgrind参数配置详解_听雨时节的博客-CSDN博客_valgrind 参数
使用 Valgrind 检测 C++ 内存泄漏 | Senlin's Blog
【Linux】Valgrind工具集详解_熠熠微光的博客-CSDN博客_linux valgrind
DEBUG神器valgrind之memcheck报告分析_学之之博未若知之之要知之之要未若行之之实的博客-CSDN博客
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)