Windows 有一个好的 Valgrind 替代品吗?
当我发现 Valgrind 仅适用于 Linux 时,我正在研究 Valgrind 来帮助改进我的 C 编码/调试 - 我没有其他需要或兴趣将我的操作系统迁移到 Linux,所以我想知道是否有一个同样好的适用于 Windows 的程序。
I was looking into Valgrind to help improve my C coding/debugging when I discovered it is only for Linux - I have no other need or interest in moving my OS to Linux so I was wondering if there is a equally good program for Windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(30)
我使用 Insure++,它在查找 C++ 内存泄漏/损坏和许多其他错误(如未初始化的变量、指针错误、字符串等)方面做得非常出色,它还可以进行可视化“代码覆盖率”和运行时内存使用等...这使我更有信心你的代码..你可以尝试一下试用版本..
I used Insure++ which does excellent job in finding c++ memory leaks/corruptions and many other bugs like uninitialized variables, pointer errors, strings etc., It also does visual "Code coverage" and run time memory usage etc.. which give more confident on your code.. You can try it for trail version..
您可能想了解 Mozilla 针对内存泄漏所做的事情。他们工具箱中的一个工具是 Hans Boehm 垃圾收集器,用作内存泄漏检测器.
You might want to read what Mozilla is doing regarding memory leaks. One tool in their toolbox is the Hans Boehm garbage collector used as memory leak detector.
您可以尝试 RuntimeChecker 试用版或 IBM Purify 试用版。
免费的解决方案是在 Visual Studio 中使用以下代码:
只需将其写入所有内容的顶部.cpp 文件。
当停止调试运行时,这将检测应用程序的内存泄漏并将其列在输出窗口中。双击内存泄漏行将突出显示分配内存但从未释放内存的行。这可能对您有帮助:http://www.flipcode.com/archives/How_To_Find_Memory_Leaks.shtml
You can give a try to RuntimeChecker trial ot to IBM Purify trial..
A free solution would be to use the following code in Visual Studio:
Just write this in the top of all your cpp files.
This will detect memory leaks of your application whenc stopping debug run and list them in the output window. Double clicking on a memory leaks line will higlight you the line where memory is allocated and never released. This may help you : http://www.flipcode.com/archives/How_To_Find_Memory_Leaks.shtml
正如 jakobengblom2 指出的那样,valgrind 有一套工具。根据您所讨论的窗口类型,有不同的窗口对应部件。我在这里只提到OSS或免费工具。
1. MemCheck:
内存博士。它是一个相对较新的工具,在 Windows 7 上运行得很好。我最喜欢的功能是它在报告中对相同泄漏的分配堆栈进行分组。
http://code.google.com/p/drmemory/
我还使用过 UMDH( http://support.microsoft.com/kb/268343 )并发现它非常有用且简单设置。它适用于Win2000到Win7。
AppVerifier 是 Windows 原生代码开发人员必备的工具,它的“内存”检查器可以完成类似的工作
http://msdn.microsoft.com/en -us/library/dd371695%28v=vs.85%29.aspx
2. Callgrind:
我最喜欢的是verysleepy ( http://www.codersnotes.com/sleepy )它很小但非常有用且易于使用。
如果您需要更多功能,AMD CodeAnalyst™性能分析器是免费的:
http://developer.amd.com/documentation/videos/pages/introductiontoamdcodeanalystperformanceanalyzer.aspx
Windows 性能分析工具是 Microsoft 免费提供的,不太好用,但如果您愿意花时间,还是可以完成工作的。 http://blogs .microsoft.co.il/blogs/sasha/archive/2008/03/15/xperf-windows-performance-toolkit.aspx
下载:
http://msdn.microsoft.com/en-us/performance/cc752957
3. Massif:
Windows 上类似(不完全匹配)的免费工具有:
来自 sysinternals 的 VMMap:http://technet.microsoft.com/en-us/sysinternals/dd535533
!windbg 中的heap 命令:http://hacksoflife.blogspot.com/2009/06/heap-debugging-memoryresource-leak-with.html
4. Cachegrind:
上面提到的Windows性能工具具有一定程度的L2缓存未命中分析功能,但不如Cachegrind那么好和易于使用。
5. DRD:
尚未在 Windows 上找到任何免费且功能强大的工具,我能找到的唯一稍微接近的 Windows 免费工具是“锁定”检查器
应用程序验证器:
http://msdn.microsoft.com/en -us/library/dd371695%28v=vs.85%29.aspx
As jakobengblom2 pointed out, valgrind has a suit of tools. Depending which one you are talking about there are different windows counter parts. I will only mention OSS or free tools here.
1. MemCheck:
Dr. Memory. It is a relatively new tool, works very well on Windows 7. My favorite feature is that it groups the same leaks' allocation stacks in the report.
http://code.google.com/p/drmemory/
I have also used UMDH( http://support.microsoft.com/kb/268343 ) and found it quiet useful and easy to setup. It works from Win2000 to Win7.
AppVerifier is a must have swissknife for windows native code developers, its "memory" checker does similar job
http://msdn.microsoft.com/en-us/library/dd371695%28v=vs.85%29.aspx
2. Callgrind:
My favorite is verysleepy ( http://www.codersnotes.com/sleepy ) It is tiny but very useful and easy to use.
If you need more features, AMD CodeAnalyst™ Performance Analyzer is free:
http://developer.amd.com/documentation/videos/pages/introductiontoamdcodeanalystperformanceanalyzer.aspx
Windows Performance Analysis tools is free from Microsoft, not very easy to use but can get the job done if you are willing to spend the time. http://blogs.microsoft.co.il/blogs/sasha/archive/2008/03/15/xperf-windows-performance-toolkit.aspx
Download:
http://msdn.microsoft.com/en-us/performance/cc752957
3. Massif:
Similar(not quite exact match) free tools on windows are:
VMMap from sysinternals : http://technet.microsoft.com/en-us/sysinternals/dd535533
!heap command in windbg : http://hacksoflife.blogspot.com/2009/06/heap-debugging-memoryresource-leak-with.html
4. Cachegrind:
Above mentioned Windows Performance Tools has certain level of L2 cache miss profiling capability but not quite as good and easy to use as Cachegrind.
5. DRD:
Haven't found anything free and as powerful on Windows yet, the only free tool for windows I can find that is slightly close is the "lock" checker in
AppVerifier:
http://msdn.microsoft.com/en-us/library/dd371695%28v=vs.85%29.aspx
为什么不使用 Valgrind + Wine 来调试您的 Windows 应用程序?看
http://wiki.winehq.org/Wine_and_Valgrind
(Chromium 使用它来检查 Windows 版本的内存错误; 看
build.chromium.org
并查看实验或记忆瀑布,并搜索葡萄酒。)
还有记忆博士,请参阅
dynamorio.org/drmemory.html
Why not use Valgrind + Wine to debug your Windows app? See
http://wiki.winehq.org/Wine_and_Valgrind
(Chromium uses this to check the Windows version for memory errors; see
build.chromium.org
and look at the experimental or memory waterfalls, and search for wine.)
There's also Dr. Memory, see
dynamorio.org/drmemory.html
一些更好的商业工具:
Some more good commercial tools:
对于 Visual C++,请尝试Visual Leak Detector。当我使用它时,它检测到 new 调用中的内存泄漏,并返回泄漏源代码中的实际行。最新版本可在 http://vld.codeplex.com/ 找到。
For Visual C++, try Visual Leak Detector. When I used it, it detected a memory leak from a
new
call and returned the actual line in source code of the leak. The latest release can be found at http://vld.codeplex.com/.您正在使用的 Windows 开发环境可能包含其自己的工具。例如,Visual Studio 允许您检测和隔离内存程序中的泄漏
Development environment for Windows you are using may contain its own tools. Visual Studio, for example, lets you detect and isolate memory leaks in your programs
我想列出一些工具,希望对您有所帮助,
请阅读这篇文章了解更多详细信息
i would like to list some tool , hope will be useful
read this article for more detail
尝试 DUMA
Try DUMA
Pageheap.exe 是 Windows 调试工具的一部分。它是免费的,基本上是一个自定义内存分配器/解除分配器。
请参阅http://support.microsoft.com/kb/286470
There is Pageheap.exe part of the debugging tools for Windows. It's free and is basically a custom memory allocator/deallocator.
See http://support.microsoft.com/kb/286470
与 Visual Studio 结合使用时,我通常使用 Visual Leak Detector 或简单地使用 _CrtDumpMemoryLeaks(),这是一个 win32 api 调用。两者都没什么特别的,但他们完成了工作。
In combination with Visual Studio I generally use Visual Leak Detector or simply _CrtDumpMemoryLeaks() which is a win32 api call. Both are nothing fancy but they get the job done.
我过去有机会使用 Compuware DevPartner Studio,效果非常好,但它相当昂贵。
更便宜的解决方案可能是 GlowCode,我刚刚使用了 5.x 版本,尽管存在一些问题在附加到我需要调试的进程时,它运行得很好。
I had the chance to use Compuware DevPartner Studio in the past and that was really good, but it's quite expensive.
A cheaper solution could be GlowCode, i just worked with a 5.x version and, despite some problems in attaching to a process i needed to debug, it worked quite well.
我一直很喜欢 Memory Validator,它来自一家名为 Software Verification 的公司。
I've been loving Memory Validator, from a company called Software Verification.
Viusual Studio 可以帮助检测内存泄漏本身。请参阅 Microsoft Visual C++ 提示和技巧 -> “内存泄漏”部分。
另请参阅SO中的帖子
虽然是真实的只能通过 Visual Studio 的团队版进行跟踪。
Viusual Studio can help detecting memory leaks itself. See Microsoft Visual C++ Tips and Tricks -> "Memory Leaks" section.
See also this post in SO
Although real tracing is only possible with the Team Edtion of Visual Studio.
请参阅软件 QA 测试和测试工具上的“源测试工具”链接类似工具列表的资源页面。
我过去曾使用 BoundsChecker、DevPartner Studio 和 Intel V-Tune 进行分析。我最喜欢V-Tune;您可以模拟各种英特尔芯片组,它会给您有关如何优化该平台的提示。
See the "Source Test Tools" link on the Software QA Testing and Test Tool Resources page for a list of similar tools.
I've used BoundsChecker,DevPartner Studio and Intel V-Tune in the past for profiling. I liked V-Tune the best; you could emulate various Intel chipsets and it would give you hints on how to optimize for that platform.
Jochen Kalmbach 的内存泄漏检测器符合资格吗?
PS:最新版本的 URL 隐藏在文章评论线程的某个位置。
Does Jochen Kalmbach's Memory Leak Detector qualify?
PS: The URL to the latest version is buried somewhere in the article's comment thread.
LeakDiag、UMDH、App Verifier、DebugDiag 都是提高代码稳健性和查找内存泄漏的有用工具。
LeakDiag, UMDH, App Verifier, DebugDiag, are all useful tools to improve robustness of code and find memory leaks.
Boost Test 库可以检测内存泄漏。
The Boost Test library can detect memory leaks.
Purify 怎么样?
How about the Purify?
尝试英特尔的 Inspector XE 产品,它可以帮助您检测内存和线程问题: http://software.intel.com/en-us/articles/intel-inspector-xe/
Try Intel's Inspector XE product which can help you detect both memory and threading issues: http://software.intel.com/en-us/articles/intel-inspector-xe/
也许 CodeSnitch 会是您想要的东西? http://www.entrek.com/codesnitch.html
Perhaps CodeSnitch would be something you're after? http://www.entrek.com/codesnitch.html
如果您使用 Borland/CodeGear/Embarcadero C++ Builder 进行开发,则可以使用 CodeGuard。
If you are developing with Borland/CodeGear/Embarcadero C++ Builder, you could use CodeGuard.
所有分析器或多或少都包括检查内存泄漏并显示分配内存时的堆栈。
我可以推荐Intels Parallel Inspector。使用简单,无需重新编译。试用版运行 30 天。
GlowCode 和 AtromatedQA 也包括此类功能。他们都提供免费试用。
相比之下,Compuware DevPartner(又名 BoundsChecker)需要减慢“检测”重新编译的速度,并且应用程序在检查错误时运行速度也会变慢。而且 BoundsChecker 根本无法与 64 位 evsrions 一起使用。我们放弃了那个工具。
More or less all Profilers include checking for memory leaks and show you the stack when the memory was allocated.
I can recommend Intels Parallel Inspector. Simple to use and no recompilation needed. The trial version runs for 30 days.
GlowCode and AtromatedQA also include such capabilites. They all offer free trials.
Compuware DevPartner (aka BoundsChecker) in Contrast needs a slowed down "instrumentation" recompile and the application also runs slower when checking for errors. And BoundsChecker can not work with 64 Bit evsrions at all. We gave up on that tool.
我用过的最好的工具是 DevPartner BoundsChecker - 它不是免费的,但有一个评估时期。
The best tool I ever used is DevPartner BoundsChecker - it's not free but it has an evaluation period.
您列表中的另一个内存工具:内存验证器。
不是免费的,但远没有 Purify 或 Boundschecker 那么贵。
Another memory tool for your list: Memory Validator.
Not free, but nowhere near as expensive as Purify or Boundschecker.
如果您不害怕 mingw,这里有一些链接(有些可能适用于 MSVC)...
http://betterlogic.com/roger/?p=1140
If you're not afraid of mingw, here are some links (some might work with MSVC)...
http://betterlogic.com/roger/?p=1140
我们刚刚完成一个用于 Windows 的内存安全检查工具,它可以处理 GCC 和 Micrsoft Visual C(不是C++ 还没有),并且正在寻找 Beta 测试人员。
编辑 2011 年 6 月 12 日:不再是 Beta,现在是 GCC 和 Microsoft Visual Studio C 的生产版。
We are just completing a Memory Safety checking tool for Windows, that handles GCC and Micrsoft Visual C (not C++ yet), and are looking for Beta testers.
EDIT June 12, 2011: Not Beta anymore, now production for GCC and Microsoft Visual Studio C.
我今天发现了这个 SF 项目:
http://sourceforge.net/p/valgrind4win/wiki/Home /
他们正在将 valgrind 移植到 Windows。也许几年后我们就会在 Windows 上拥有可靠的 valgrind。
I found this SF project today:
http://sourceforge.net/p/valgrind4win/wiki/Home/
They are porting valgrind to Windows. Probably in several years we will have a reliable valgrind on windows.
看看这个问题:Windows 有一个好的 Valgrind 替代品吗?。尽管询问了 valgrind 的一般替代品,但它主要讨论内存泄漏检测器而不是竞争条件检测。
Check out this question: Is there a good Valgrind substitute for Windows? . Though general substitute for valgrind is asked, it mainly discusses memory leak detectors and not race conditions detections.