linux 下C++内存泄漏检测工具

1.Valgrind

常用操作

valgrind --tool=memcheck --leak-check=full --show-reachable=yes --trace-children=yes  --log-file=./mem.log  ./a.out 

完成内存检测后,查看日志,主要看这里

==4869== LEAK SUMMARY:
==4869==    definitely lost: 0 bytes in 0 blocks
==4869==    indirectly lost: 12 bytes in 1 blocks
==4869==      possibly lost: 0 bytes in 0 blocks
==4869==    still reachable: 0 bytes in 0 blocks
==4869==         suppressed: 0 bytes in 0 blocks

 出现内存泄漏后,在往上找泄漏的大概位置。

==4869==    at 0x4006041: calloc (vg_replace_malloc.c:593)
==4869==    by 0x804C550: collector_new (in /home/yang/WorkStation/Task/t9.8.7/iptv_center_server/iptv_center_server)
==4869==    by 0x804E88F: start_task (in /home/yang/WorkStation/Task/t9.8.7/iptv_center_server/iptv_center_server)
==4869==    by 0x804D8C5: main (in /home/yang/WorkStation/Task/t9.8.7/iptv_center_server/iptv_center_server)

 参考:

https://blog.csdn.net/u012662731/article/details/78652651

 

上一篇:Linux磁盘管理及LVM讲解


下一篇:Linux文件恢复与密码破解