c/c++ 使用valgrind检查内存泄漏
2020-04-14 16:01:48来源:博客园 阅读 ()
c/c++ 使用valgrind检查内存泄漏
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
原文链接:https://www.cnblogs.com/xiaoshiwang/p/12701947.html
如有疑问请与原作者联系
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- C++ 转换函数搭配友元函数 2020-06-10
- C++ 自动转换和强制类型转换(用户自定义类类型) 2020-06-10
- C++ rand函数 2020-06-10
- C++ 友元函数 2020-06-10
- C++ 运算符重载 2020-06-10
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash