linux under the C ++ memory leak detection tools

1.Valgrind

Common Operations

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

After completing the memory test, view logs, mainly to see here

==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

 After a memory leak, looking up at the approximate location of the leak.

==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)

 reference:

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

 

Guess you like

Origin www.cnblogs.com/yangxinrui/p/11373651.html