I have a memory leak in my .NET application. In the meantime I know which objects are leaked. But there should be no references to it. How can I find the reference pathes? Which tool is the right solution for it?
Asked
Active
Viewed 669 times
1
-
1WinDbg or .Net Memory Profiler (not free). Get a full memory dump and then open it in one of the tools. – xxbbcc Sep 01 '15 at 15:11
-
This could be helpful to start (not sure): http://stackoverflow.com/questions/28102678/iterating-through-dumpheap-output-to-read-value-at-memory-offset – xxbbcc Sep 01 '15 at 15:26
-
Also, SOS.dll - https://msdn.microsoft.com/en-us/library/bb190764%28v=vs.110%29.aspx – xxbbcc Sep 01 '15 at 15:29
2 Answers
3
I appreciate you like to learn how things work under the hood. This should give you a starting point:
- Create a good crash dump for .NET.
- Get WinDbg from Microsoft. You can install both versions, x86 and x64 so that you can debug both kinds of dumps.
- Open the crash dump in WinDbg (use correct bitness).
- Set up the symbols
- Load the .NET extension,
.loadby sos clr
(for .NET 4.x, else see here) - Find the object you're looking for using
!dumpheap -type MyType
- Use
!gcroot
to see whether the object has root references or not.
For specific problems, ask questions using sos and windbg tags.

Community
- 1
- 1

Thomas Weller
- 55,411
- 20
- 125
- 222
1
I would suggest Red gate ANTS Memory profiler and have a look at Walkthrough: Using ANTS Memory Profiler to track down a memory leak

CharithJ
- 46,289
- 20
- 116
- 131