views:

112

answers:

5

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

+5  A: 

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

Stephen Newell
A: 

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

antti.huima
+1  A: 

valgrind --leak-check=full

f0ster
A: 

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

Tim Sylvester
+1  A: 

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

Billy ONeal