c/c++语言开发共享c/c++ 使用valgrind检查内存泄漏

c/c++ 学习互助QQ群:877684253 本人微信:xiaoshitou5854 …

ys@ysm:tests$ valgrind --tool=memcheck --leak-check=full ./a.out ==7503== memcheck, a memory error detector ==7503== copyright (c) 2002-2013, and gnu gpl'd, by julian seward et al. ==7503== using valgrind-3.10.1 and libvex; rerun with -h for copyright info ==7503== command: ./a.out ==7503== tid=7503, constructing 0x5c3e0b0 tid=7510, 0x5c3e0b0 name=only one tid=7503, 0x5c3e0b0 name=only one, changed tid=7503, constructing testnodestroy 0x5c3e3c0 with valgrind, you should see 1-byte memory leak. tid=7503, destructing 0x5c3e0b0 only one, changed ==7503== ==7503== heap summary: ==7503==     in use at exit: 1 bytes in 1 blocks ==7503==   total heap usage: 7 allocs, 6 frees, 476 bytes allocated ==7503== ==7503== leak summary: ==7503==    definitely lost: 0 bytes in 0 blocks ==7503==    indirectly lost: 0 bytes in 0 blocks ==7503==      possibly lost: 0 bytes in 0 blocks ==7503==    still reachable: 1 bytes in 1 blocks ==7503==         suppressed: 0 bytes in 0 blocks ==7503== reachable blocks (those to which a pointer was found) are not shown. ==7503== to see them, rerun with: --leak-check=full --show-leak-kinds=all ==7503== ==7503== for counts of detected and suppressed errors, rerun with: -v ==7503== error summary: 0 errors from 0 contexts (suppressed: 0 from 0) ys@ysm:tests$ g++ singleton_test.cc -std=c++11 -lmuduo_base -pthread -g ys@ysm:tests$ valgrind --tool=memcheck --leak-check=full ./a.out ==7529== memcheck, a memory error detector ==7529== copyright (c) 2002-2013, and gnu gpl'd, by julian seward et al. ==7529== using valgrind-3.10.1 and libvex; rerun with -h for copyright info ==7529== command: ./a.out ==7529== tid=7529, constructing 0x5c3e0b0 tid=7530, 0x5c3e0b0 name=only one tid=7529, 0x5c3e0b0 name=only one, changed tid=7529, destructing 0x5c3e0b0 only one, changed ==7529== ==7529== heap summary: ==7529==     in use at exit: 0 bytes in 0 blocks ==7529==   total heap usage: 6 allocs, 6 frees, 475 bytes allocated ==7529== ==7529== all heap blocks were freed -- no leaks are possible ==7529== ==7529== for counts of detected and suppressed errors, rerun with: -v ==7529== error summary: 0 errors from 0 contexts (suppressed: 0 from 0) 

c/c++ 学习互助qq群:877684253 本人微信:xiaoshitou5854

c/c++ 使用valgrind检查内存泄漏

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/c-cdevelopment/599803.html

(0)
上一篇 2021年5月9日
下一篇 2021年5月9日

精彩推荐