linux命令如下:valgrind --tool=memcheck --leak-check=full ./a.out
若没有valgrind工具,ubuntu下需要sudo apt-get install valgrind
如下:
举例说明:
 #include <iostream>
using namespace std; int main(int argc, char *argv[])
{
string* s = new string("hello world");
cout<<*s<<endl; int* m = new int();
cout<<*m<<endl; delete m; return ;
} //running:
nol@nol-VirtualBox:~/desktop$ valgrind --tool=memcheck --leak-check=full ./a.out
==== Memcheck, a memory error detector
==== Copyright (C) -, and GNU GPL'd, by Julian Seward et al.
==== Using Valgrind-3.11. and LibVEX; rerun with -h for copyright info
==== Command: ./a.out
====
hello world ====
==== HEAP SUMMARY:
==== in use at exit: , bytes in blocks
==== total heap usage: allocs, frees, , bytes allocated
====
==== bytes in blocks are definitely lost in loss record of
==== at 0x4C2E0EF: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==== by 0x400C40: main (in /home/nol/desktop/a.out)
====
==== LEAK SUMMARY:
==== definitely lost: bytes in blocks
==== indirectly lost: bytes in blocks
==== possibly lost: bytes in blocks
==== still reachable: , bytes in blocks
==== suppressed: bytes in blocks
==== Reachable blocks (those to which a pointer was found) are not shown.
==== To see them, rerun with: --leak-check=full --show-leak-kinds=all
====
==== For counts of detected and suppressed errors, rerun with: -v
==== ERROR SUMMARY: errors from contexts (suppressed: from )
nol@nol-VirtualBox:~/desktop$
 
 
 
 

最新文章

  1. DLL导出函数和类的定义区别 __declspec(dllexport)
  2. cookie小析
  3. Codeforces Round #172 (Div. 2)
  4. 如何在CALayer设置滤镜
  5. SQLite使用方法 SQLiteOpenHelper操作(转)
  6. freeCodeCamp:Missing letters
  7. 国产CPU研究单位及现状
  8. CF 567C Geometric Progression
  9. dotnet webservice处理数据量过大,ajax请求返回500错误解决方案
  10. MongoDb 快速入门教程
  11. mysql优化 | 存储引擎,建表,索引,sql的优化建议
  12. 第十五节 JS面向对象实例及高级
  13. C++中关于字符串的一些API
  14. ipfs webui 管理界面
  15. spring 配置文件的头部 xmls
  16. C++复习:继承与派生
  17. burpsuite的使用(一)
  18. 【cs229-Lecture10】特征选择
  19. [py][mx]django-解决注册用户已存在,激活链接判断
  20. HDU 2544:最短路

热门文章

  1. mac下google插件SwitchyOmega笔记
  2. RoadFlow开源工作流源码-项目架构分析
  3. day 89 DjangoRestFramework学习三之认证组件、权限组件、频率组件、url注册器、响应器、分页组件
  4. Python3 From Zero——{最初的意识:000~Initial consciousness}
  5. ajax 接收json数据的进一步了解
  6. docker集群管理之swarm
  7. mysql查询小技巧
  8. Trip
  9. mysql连接卡死,很多线程sleep状态,导致CPU中mysqld占用率极高
  10. Linux命令速查手册(第2版)学习