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?
!dumpheap -stat
, basically. There's probably also software that tries to make a nice interface out of this, but I have no experience, nor is SO the place for software recommendations. – Psychotechnology!dumpheap -stat
, can you give me one more tip? – Marchant!dumpheap
to work, but it's best to capture a 32-bit dump instead --procdump
will do the right thing by default. Alternatively, uncheck the "prefer 32-bit" checkbox when building your .NET app so it runs as native 64-bit. – Psychotechnology%SystemRoot%\SysWOW64\TaskMgr.exe
. Now I do have a "dumpheap -stat", which gives some information, but the whole thing looks type-based: for every type or class, there's an entry, while in heap_stat the result was object-based: for every object, there was an entry. That allowed me to see all the collections and their count, revealing interesting information about large collections. Is such a thing possible here? – Marchant-stat
just summarizes things so you have a high-level view at where the memory goes, but if you really want to get down to the object level that's basically what you get when you leave off-stat
. You cannot get things like the size of a managed collection with just!dumpheap
, though, as that requires drilling down into object properties. For that you also need things like!DumpObj
and possibly some WinDbg scripting. It's been a while since I've had to use SOS to diagnose things, so I couldn't cough up a ready to run script. – Psychotechnology!dumpheap
(without stat) and I see a lot of ununderstandable things :-) but those are most probably due to lack of debugging symbols. I'm trying to get that working and the hyperlinks in the!dumpheap
results indeed launch!DumpObj
commands. I also need to refresh my mind about those things (it's been from 2019 and it was in C++), I'm sure I'll manage. Thanks a lot for your help. – Marchant