This commands are the simplest commands to analyze the dump file for .Net,
this commands requires the WinDbg SOS extension from Microsoft, to load the those use
the following command
Failed to load data access DLL, 0x80004005For .NET 2.0 and above
.loadby sos mscorwks
For .NET 1.1 (the SOS extension has to be downloaded separately)
.load C:\Program Files\Debugging Tools for Windows\clr10\sos.dll
Simple commands
List native threads
~* kb ffff
List clr threads
~* e !clrstack
List clr threads with arguments to the function
~* e !clrstack -p
List all classes located on the CLR heaps order by size of all it object instances
!dumpheap -stat
List all objects in the large object heap
!dumpheap -min 85000
List numer of objects in the finalize queue
!FinalizeQueue
Examine what the finalizer queue does
List all threads
!threads
find the finalizer queue and examine the stack
!clrstack
Advanced commands
Dumps the ASP.NET runtime cache
!dumpaspnetcache -stat
List the size of all objects in the ASP.NET runtime cache
foreach (cachedObject {!dumpaspnetcache -short}) {!objsize ${cachedObject}}
List all objects on the heap
!dumpheap
MT Count TotalSize Class Name
...
6639decc 10000 720000 System.Web.Caching.CacheEntry
790fc6cc 25306 986146448 System.String
List all object of a certain type (here CacheEntry because mt=790fc6cc, from the command above)
!dumpheap -mt 790fc6cc
Address MT Size
...
3fb319a0 790fc6cc 262168
Dump the specific object (at address 3fb319a0, from the command above)
!dumpobj 3fb319a0
Extract an assembly from the dump
0:000> lm
start end module name
...
05020000 05194000 EPiServer (deferred)
!SaveModule 05020000 c:\temp\TheDumpsEPiServer.DLL
List certain variable from a specific type
Locate the offset address of the variable by dump an object of the certain type.
0:000> !do 1007dc6c
Name: System.Web.Caching.CacheDependency
MethodTable: 66149114
EEClass: 65f86d94
Size: 36(0x24) bytes
(C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll)
Fields:
MT Field Offset Type VT Attr Value Name
793309a0 40013fb 4 System.String 0 instance 1007e08c _uniqueID
...
here is the offset for the variable "_uniqueID" 0x4, use it with the poi function to use as argument for !dumpObj. Here we want to dump a string so we uses the "-nofields" argument to get a more compact output
.foreach (cd { !dumpheap -type System.Web.Caching.CacheDependency -short }) { !do -nofields poi(${cd}+0x4)}
References
Microsoft SOS commands