R – How to use !gcroot

debuggingnetprofilingsoswindbg

From within visual studio immediate window with SOS debugging extension loaded I can do

!dumpheap -stat

Then I get something like this:

    total 108,014 objects
    Statistics:
    MT         Count  TotalSize  Class Name
   ...
    0x00be209c 135   714108    System.Object[]
    0x79b925c8 218   2659728  System.String
    0x00be2c3c 78986 10,705,064 System.Byte[]
    Total 208,014 objects, Total size: 36,259,364

How can I call !gcroot on some of the System.Byte[] instances now? I would first have to find the adress of them. But using !dumpheap -type System.Byte[] is surely a bad idea because that will give me an endless list and since the immediate window seems to be slow it takes more than 20 minutes to list them – duirng that time visual studio is not usable. Is there a sceret trick how I could call !gcroot on some of the byte arrays?

Best Answer

You can filter out the noise using the -min -max switches, I guess that your problem is with the large objects so call !dumpheap -min -type System.Byte[] where is large enough to filter out the noise.