内存泄漏检测器 [英] Memory Leak Detector

查看:78
本文介绍了内存泄漏检测器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



您能否建议我一个适用于c ++的无内存泄漏工具.

目标:免费工具应该能够识别所有由于内存分配运算符,线程,套接字,文件,事件等导致的内存泄漏.
环境:Windows7上的Microsoft VisualStudio 2005上的C ++编译器.


问候
Narayana Reddy.L

Hi,

Could you please suggest me one memory leak free tool for c++.

Objective : Free tool should able to identify all memory leaks, that are caused due to memory allocation operators, threads, sockets, files, events etc..
Environment : C++ compiler on Microsoft VisualStudio 2005 on Windows7.


Regards
Narayana Reddy.L

推荐答案

直接从CodeProject看一下这些文章.他们肯定会提供您所需要的:
http://www.codeproject.com/search.aspx?q =内存+泄漏+ c%2b%2b& doctypeid = 1%3b2%3b3 [
Have a look at these articles, right from CodeProject. They will most certainly provide what you need:
http://www.codeproject.com/search.aspx?q=memory+leak+c%2b%2b&doctypeid=1%3b2%3b3[^]


我建​​议您不是寻找内存泄漏检测器",而是寻找"内存调试器".

Wikipedia提供了很好的参考列表,其中一些工具是开源的.请参阅:
http://en.wikipedia.org/wiki/Memory_debugger [ http://en.wikipedia.org/wiki/Memory_debugger#List_of_memory_debugging_tools [
I would advise you to look not for "memory leak detector", but for "memory debugger".

Wikipedia provides a good list of references, some of those tools are open-source. Please see:
http://en.wikipedia.org/wiki/Memory_debugger[^],
http://en.wikipedia.org/wiki/Memory_debugger#List_of_memory_debugging_tools[^].

Good luck,
—SA


不是获取泄漏检测器,而不是首先泄漏内存如何?

这是2012年,自2003年以来(对于VC ++,是2006年-VC ++ 2005的Service Pack),C ++拥有了您所需的所有工具,从不会泄漏任何类型的资源,更不用说内存了.如果您泄漏任何内容,则意味着您在做一些狡猾的事情,而您的时间最好花在回头再重写代码上.不要试图塞孔,而要避开冰山.

这很容易避免-到处都可以看到指针或内置数组[1],将其替换为局部变量std :: unique_ptr,std :: shared_ptr或std :: vector.这样做,根据应用领域的不同,您可以减少75%到99%的问题数量.

[1]除了某些例外,从资源管理的角度来看,const数组是无害的.
Instead of getting a leak detector how about not leaking memory in the first place?

This is 2012 and since 2003 (2006 in the case of VC++ - the service pack for VC++2005) C++ has had all the tools you need to NEVER leak resources of any kind, let alone memory. If you leak anything it means you''re doing something dodgy and your time would be better spend going back and rewriting your code. Don''t try and plug the holes, avoid the iceberg instead.

It''s pretty easy to avoid - everywhere you see a pointer or built in array [1] replace them with either a local variable, std::unique_ptr, std::shared_ptr or std::vector. Do that and you''ll reduce the number of problems you have between 75% to 99% depending on your application area.

[1] With some exceptions, const arrays are pretty harmless from a resource management point of view.


这篇关于内存泄漏检测器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆