Can DebugDiag generate reports with “inclusive size” like Visual Studio 2013

倾然丶 夕夏残阳落幕 提交于 2019-12-02 01:49:20

DebugDiag

DebugDiag 2 has totally been rewritten and is now a set of executables (EXE and DLL). It is no longer a set of scripts which you could easily modify to include additional information that you want to be there.

The output of DebugDiag is simiar to what you see in WinDbg+SOS's !dumpheap -stat output:

...
575a4518    11547       560508 System.Object[]
575d37b8       91       892344 System.Byte[]
575d2ee4     3488       927512 System.Int32[]
575d0d48    72920      6939284 System.String
Total 120639 objects

Other approaches

SOS !do <address> gives only the size without children, but there is SOS !objsize <address>, which seems to include children (can't cross check with Visual Studio 2013, only have 2012):

0:008> !do 0b938584 
Name: SomeClass
MethodTable: 08947c0c
EEClass: 08956c38
Size: 292(0x124) bytes
...

0:008> !objsize 0b938584 
sizeof(0b938584) =        11728 (      0x2dd0) bytes (SomeClass)

To do that for all objects on the heap, you can execute !objsize for each object in a loop:

.foreach (address {!dumpheap -short}) {!objsize ${address}}

The only command I know that lists property values recursively is SOSEX's !mdt <address> -r, but it will not output the size.

Analyzing root objects only with Pykd

Starting point for a Pykd script:

0:000> .loadby sos clr; .loadby sos mscorwks
0:000> .load <full path>\sosex.dll
0:000> .load <full path>\pykd.pyd
0:000> !pycmd
>>> gch = dbgCommand("!gch")
>>> lines = gch.split('\n')
>>> for line in lines: dprint(dbgCommand("!objsize "+line[34:50]))
...

Press Enter after ... appears. Note that [34:50] this might need to be adapter for 32 bit.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!