I have several hundred instances of MyClass present in managed heap. Some of these are in large-object heap. Below is how various heap structure looks
0:000> !EEHeap -gc
Number of GC Heaps: 1
generation 0 starts at 0x0000000002df9de8
generation 1 starts at 0x0000000002dc6710
generation 2 starts at 0x0000000002a01000
ephemeral segment allocation context: none
segment begin allocated size
0000000002a00000 0000000002a01000 0000000002e3c2c0 0x43b2c0(4436672)
Large object heap starts at 0x0000000012a01000
segment begin allocated size
0000000012a00000 0000000012a01000 000000001a5ed558 0x7bec558(129942872)
000000002a980000 000000002a981000 00000000328110b8 0x7e900b8(132710584)
0000000033e00000 0000000033e01000 000000003bd80d78 0x7f7fd78(133692792)
000000001daf0000 000000001daf1000 0000000025996188 0x7ea5188(132796808)
00000000542b0000 00000000542b1000 000000005a4bf100 0x620e100(102818048)
000000005c2b0000 000000005c2b1000 000000006344df88 0x719cf88(119132040)
000000007fff0000 000000007fff1000 00000000878bfbc0 0x78cebc0(126675904)
Total Size: Size: 0x34956418 (882205720) bytes.
------------------------------
GC Heap Size: Size: 0x34956418 (882205720) bytes.
My questions are
1. How can I find addresses of all instances of MyClass that are in large-object heap.
2. Is there anyway to run !ObjSize on those instances of MyClass that are in large-object heap?
To get all objects on LOH you can use SOS !dumpheap
with the -min
option.
!dumpheap -min 85001
To limit the output to the type of objects you're looking for, first determine the method table (MT) of your object by doing a
!dumpheap -type <MyClass>
Address MT Size
03653250 785037b8 10485776
...
Since !dumpheap
will look for substrings in classes, this is needed to really reduce the output to the type of your class. Then use -mt
for the method table you found:
!dumpheap -min 85001 -mt <MethodTable>
To minimize the output to the addresses only, add the -short
parameter, so you get
!dumpheap -min 85001 -mt <MethodTable> -short
You can then use the addresses in a foreach loop
.foreach (address {!dumpheap -min 85001 -mt <MethodTable> -short}) {!do ${address}}
Since the output may he large in case of many object, consider logging everything into a file
.logopen c:\debug\logs\largeobjects.txt