- Start up windbg and attach (F6).
- Make sure you pick the right version (x86/x64) and run as admin if your app is running as admin.
- Make sure you have the microsoft symbol servers turned on in Visual Studio -> tools -> options -> debugging -> symbols
Load
.loadby sos clr
Dump the heap
!DumpHeap -stat
Find the biggest type
!DumpHeap -type Foo
Pick an object
!gcroot [address]
Trace the roots to see what is keeping it alive You can use
!dumpobj [address]
To look at the fields of the object if that is helpful. Do this for a few instances so you find old and new ones (Don't forget some are legit). With thanks to @tathamoddie
To look deeper into gcroots, find out which generation your object is in
!GCWhere [address]
Turn on CLR GC notifications
!HandleCLRN
Enable breaking on a GC collection (in this case gen 2) and continue the debugger
!FindRoots –gen 2
g
Run the app until GC occurs and the debugger breaks then run
!FindRoots [address]
Prefer Debugger Markup Language After loading sos
.prefer_dml 1