I have simple console application (target framework 4.5.2):
using System;
public class SosTest
{
public class Foo
{
public Foo()
{
Console.WriteLine("Creation of foo");
}
}
static void Main(string[] args)
{
var n1 = new Foo();
var n2 = new Foo();
Console.WriteLine("Allocated objects");
Console.WriteLine("Press any key to invoke GC");
Console.ReadKey();
n2 = n1;
n1 = null;
GC.Collect();
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}
}
I want to see state of managed heap. I do following steps:
- Open windbg
- Open exe file of my program with windbg's "open executable" command
- Perform command to load sos
.load MicrosoftNet\Framework\v4.0.30319\sos.dll
- Perform command to see state of heap
!eeheap -gc
But during last command I get following message:
Failed to find runtime DLL (clr.dll), 0x80004005 Extension commands need clr.dll in order to have something to do.
Why does command !eeheap -gc
fail?
If it will help it is result of lm
command:
0:000> lm
start end module name
00be0000 00be8000 ConsoleApplication1 (deferred)
734c0000 73519000 MSCOREE (deferred)
74c20000 74d00000 KERNEL32 (deferred)
753d0000 75571000 KERNELBASE (deferred)
77d80000 77f03000 ntdll (pdb symbols)
I am not sure you are doing it right way or not, but i used to do it with the following command:
and after that write:
the
sxe ld clrjit
notifies debugger when clrjit module is loaded, theg
flag is for continuing execution and.loadby sos clr
will load sos debugger from location where it finds clr.dllI once watched the following the following two plural-sight courses on C# Internals by Bart de Smet and i found them great for understanding the insights of c# and clr:
C# Language Internals - Part 1
C# Language Internals - Part 2