For a previous employer, while performing dump analysis, I have regularly used heap_stat.py, based on PYKD library for Windbg.
I believe heap_stat.py script only works for C/C++ development. Is there an equivalent for C# applications?
Thanks in advance
I've tried to start up !Dumpheap -stat, but loading the SOS extension seems to be a challenge:
Windbg 32-bit:
0:000> .loadby sos clr
0:000> !dumpheap -stat
SOS does not support the current target architecture.
Windbg 64-bit:
0:000> .loadby sos clr
The call to
LoadLibrary(C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dll)
failed, Win32 error 0n193
"%1 is not a valid Win32 application."
Please check your debugger configuration and/or network access.
0:000> .load sos
0:000> !Dumpheap -stat
No export Dumpheap found
Windbg preview:
0:000> .loadby sos clr
The call to
LoadLibrary(C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos.dll)
failed, Win32 error 0n193
"%1 is not a valid Win32 application."
Please check your debugger configuration and/or network access.
0:000> .load sos
0:000> !Dumpheap -stat
No export Dumpheap found
How can I load the SOS extension and launch that !Dumpheap -stat command?
The problem
Your crash dump has the wrong bitness. Most likely nowadays that's because you have used Task Manager on a 64 bit system and created a crash dump of a 32 bit application.
Windows comes with two versions of Task Manager: a 64 bit version (
C:\Windows\System32\Taskmgr.exe) and a 32 bit version (C:\Windows\SysWOW64\Taskmgr.exe). The path names are somewhat confusing.System32refers to the native bitness of the OS, which is 64 bit. AndWoW64means Windows 32 bit on Windows 64 bit, which is 32 bit.Preventing the problem in the future
Have a look at How do I take a good crash dump for .NET? for tools that automatically detect the bitness and create a nice crash dump for you.
Microsoft does still not provide MSCORDAC DLLs (the Microsoft Common Object Runtime Data Access Component) cross-bitness. Therefore your best choice is totake 32 bit crash dumps of 32 bit .NET applications and 64 bit crash dumps of 64 bit .NET applications.
Fixing the problem if you have no other choice
However, there's a fix:
.effmach x86soswow64using.loadand the full path.loadby sos clras usualNote that the access violation exception for the first SOS command is usual. Just repeat the command.