收录日期:2019/10/18 22:21:18 时间:2009-11-11 00:42:47 标签:c++,memory-leaks

I need to get the following to analyze a memory leak issue. How to do that?

  • Orphan Block Addresses Orphan Call
  • Stack

Are there any good resources/tools to know about/fix memory leaks.

Thanks

If you're on linux, use valgrind. It's your new best friend. I'm not sure what tools are available for Windows.

valgrind --leak-check=full

The Microsoft Application Verifier performs memory analysis similar to valgrind if you are on a Windows platform.

In Windows, you can use the MiniDumpWriteDump function in dbghelp.dll.

http://stackoverflow.com/questions/1547211/how-to-create-minidump-for-my-process-when-it-crashes

This can be very helpful in tracking down errors in deployed applications because you can use your debug symbols to inspect a minidump made in the field with no debug info. It's not very useful for tracking memory leaks, however.

For memory leaks under Windows (aside from commercial tools like Purify, BoundsChecker and GlowCode, of course) you can use WinDbg from the free Debugging Tools for Windows package, along with Win32 heap tags to track down the source of memory leaks.

http://www.codeproject.com/KB/cpp/MemoryLeak.aspx

http://blogs.msdn.com/alikl/archive/2009/02/15/identifying-memory-leak-with-process-explorer-and-windbg.aspx

Yes, as J. Paulett commented, at least on the Linux platform Valgrind is an excellent starting point.