I would like to run !refs command against each address from following command
!dumpgen 2 -type System.DateTime[]
How this could be done.I know a loop can be created as follows
.foreach (myvar {!dumpgen 2 -type System.DateTime[]})
But how can I access object address that could be used in loop with !refs?
!dumpgendoes not have a-shortargument like!dumpheaphas and I'd really like to see a simpler answer than this one.Approach 1: dump a generation manually
Get the addresses of the heap
Use the addresses to limit the output to the generation you want:
Use the
-shortparameter on!dumpheap, which outputs the address only. This address of an object can then be processed by other commands.Also note: using
-typemay result in other types as well. Better use the method table with-mtsince only that guarantees the uniqueness of types. Use!name2eeif you don't get that from elsewhere.A complete session could look like this:
(Ok, all my strings seem to be in generation 0, damn :-)
Disadvantage: you need to do that for all GC heaps separately. There could be several of them.
Approach 2: decide for the generation on each single object
Another ugly solution is to
!dumpheap -shortand-typeor-mt)!gcgenHere's how to do it (formatted for readability, put it all into one line):
where
53ab0d48is the method table of the type you're looking for and"2"is the generation you want./pS 1skips the word "Gen" in the output of!gcgen.Disadvantage: might be slow since it works on all objects.