windbg + sos 调试w3wp进程内存崩溃问题
1.加载符合文件
C:\symbols;SRV*C:\symbols*http://msdl.microsoft.com/download/symbols;
2.加载sos.dll
.load C:\Windows\Microsoft.NET\Framework\v2.0.50727\SOS.dll
3.查看托管堆里面的对象大小
!dumpheap -stat
72a52524 4780 19149568 System.Int64[]
66300224 1404204 22467264 System.ServiceModel.Description.XmlName
01239298 3170 25187084 Free
6f75ac00 1692875 40629000 System.Xml.XmlDictionaryString
72a40d1c 60413 47153628 System.Reflection.Emit.__FixupData[]
66301d38 979563 50937276 System.ServiceModel.Description.MessagePartDescription
6f75b8a8 143024 59241664 System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[System.Xml.XmlDictionaryString, System.Runtime.Serialization]][]
72a52ee4 634786 82323112 System.Int32[]
72a53498 154589 83105136 System.Collections.Hashtable+bucket[]
72a24518 2153323 89750416 System.Object[]
72a50d48 4210817 305563628 System.String
72a537b8 526411 309971176 System.Byte[]
4.针对结果集里面的大对象,执行!dumpheap -mt 方法表地址
1984e140 72a537b8 262160
19892618 72a537b8 131088
198b2628 72a537b8 131088
198d2638 72a537b8 131088
1990f488 72a537b8 131088
1992f4a8 72a537b8 262160
1998af48 72a537b8 262160
199caf68 72a537b8 262160
19a0af78 72a537b8 131088
19a2cfb0 72a537b8 262160
19a6cfc0 72a537b8 262160
19aacfe0 72a537b8 262160
19aecff0 72a537b8 131088
19b0f028 72a537b8 131088
19b35090 72a537b8 131088
19b550a0 72a537b8 262160
上图列出了这类对象里面的单个对象大小。
再对它进行一次过滤,!dumpheap -min 85000 -mt 方法表地址
Adress MT Size
1984e140 72a537b8 262160
19892618 72a537b8 131088
198b2628 72a537b8 131088
198d2638 72a537b8 131088
1990f488 72a537b8 131088
1992f4a8 72a537b8 262160
1998af48 72a537b8 262160
199caf68 72a537b8 262160
19a0af78 72a537b8 131088
19a2cfb0 72a537b8 262160
19a6cfc0 72a537b8 262160
19aacfe0 72a537b8 262160
19aecff0 72a537b8 131088
19b0f028 72a537b8 131088
19b35090 72a537b8 131088
19b550a0 72a537b8 262160
5.查看大对象的根,!gcroot 1984e140
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
more info.
Scan Thread 7 OSTHread 13d8
Scan Thread 21 OSTHread 10e4
Scan Thread 22 OSTHread 1764
Scan Thread 23 OSTHread 668
Scan Thread 24 OSTHread 10f8
Scan Thread 25 OSTHread 1334
Scan Thread 26 OSTHread 1244
ESP:1c2dfb50: 1c2dfb88 (invalid object)
ESP:1c2dfc28: 1c2dfbec (invalid object)
ESP:1c2dfc2c: 1c2dfbec (invalid object)
ESP:1c2dfc64: 1c2dfbec (invalid object)
Scan Thread 27 OSTHread 1164
Scan Thread 29 OSTHread 14f0
Scan Thread 2 OSTHread a74
Scan Thread 35 OSTHread 8a0
Scan Thread 36 OSTHread 15d8
Scan Thread 37 OSTHread 17f4
Scan Thread 38 OSTHread 162c
Scan Thread 39 OSTHread 120c
Scan Thread 40 OSTHread 930
Scan Thread 41 OSTHread 15bc
Scan Thread 42 OSTHread a54
Scan Thread 44 OSTHread f8
Scan Thread 46 OSTHread 17d4
DOMAIN(01280308):HANDLE(Pinned):d013fc:Root:1206db58(System.Object[])->
6.找到对应代码,检查问题。