0

How to detect objects causing memory leaks in .net. Is it possible to detect object causing memory leaks using crash-dumps?

  • related: [How do I take a good crash dump for .NET](http://stackoverflow.com/questions/24874027/how-do-i-take-a-good-crash-dump-for-net) – Thomas Weller Sep 29 '15 at 06:15
  • also needed: [How to set up symbols in WinDbg](http://stackoverflow.com/questions/30019889/how-to-set-up-symbols-in-windbg) – Thomas Weller Sep 29 '15 at 06:29

2 Answers2

0

To detect and investigate memory leaks in .NET you have several options:

  1. Use a memory profiler tool like RedGate's ANTS (many other similar tools are available).
  2. Use WinDBG with its SOS extension.
  3. Instrument your app yourself with a memory leak detector based on weak references.

To use crash dumps in the investigation of memory leaks see this stackoverflow question and this MSDN link.

Community
  • 1
  • 1
Ladi
  • 1,274
  • 9
  • 17
0

Having one dump (and if it has been taken properly see this article) maybe, having multiple dumps most certainly.

What you can do:

  • If you haven´t already, install the Windows SDK to get the Debugging Tools for Windows
  • If you have an x86 process (note: the architecture of the process is relevant, not the architecture of the system running the process) use WinDBG (x86), otherwise use the x64 Version.
  • Go File - Open Crash Dump, locate your dump file and open it
  • assuming your process is .net 4, in the debugger enter

    .loadby sos clr followed by !dumpheap -stat

  • This will output the count and class name of managed types.

  • Having multiple dumps will make it easier for your, but certainly not as easy as being able to use a Memory profiler

Dominik
  • 3,342
  • 1
  • 17
  • 24