Case, there are a lot Memory get used by some objects with the same type. let’s say the type is String here, how can we dump all those strings.
how to, list all those object ids, and run DumpObject. .for each
here is a Demo.
static void Main(string[] args) |
//List all those string whose size is over 20K
!DumpHeap -type System.String -min 20000 0:004> !DumpHeap -type System.String -min 20000 |
the address Column displays the ddress for each string. Let me pick up the red one.
0:004> !do 013b3878
Name: System.String
MethodTable: 793308ec
EEClass: 790ed64c
Size: 40978(0xa012) bytes
(C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Fields:
MT Field Offset Type VT Attr Value Name
79332b38 4000096 4 System.Int32 1 instance 20481 m_arrayLength
79332b38 4000097 8 System.Int32 1 instance 20480 m_stringLength
793315cc 4000098 c System.Char 1 instance 2d m_firstChar
793308ec 4000099 10 System.String 0 shared static Empty
>> Domain:Value 001599c8:012d1198 <<
7933151c 400009a 14 System.Char[] 0 shared static WhitespaceChars
>> Domain:Value 001599c8:012d18cc <<
If you want to List all the strings , only display ID. 0:004> !DumpHeap -type System.String -min 20000 -short |
then run loop .foreach. .foreach (address {!DumpHeap -type System.String -min 20000 -short }) {!do ${address} } //will display all strings |
No comments:
Post a Comment