ThreadProc在GCroot上做了什么?

时间:2014-03-19 19:16:30

标签: .net windbg

我试图对托管内存泄漏进行故障排除,下面的信息对我来说没有意义,因为我希望看到一些静态方法或类似的东西,对于!gcroot命令,但找到下面的内容。

0:025> !gcroot 0000000280b0b8b8
The version of SOS does not match the version of CLR you are debugging.  Please
load the matching version of SOS for the version of CLR you are debugging.
CLR Version: 4.0.30319.18444
SOS Version: 4.0.30319.34011
Thread 1d60:
    00000000099fe9e0 000007fef72b9376 System.Net.TimerThread.ThreadProc()
        r12:  (interior)
            ->  00000003800e7948 System.Object[]
            ->  0000000180143058 System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Data.Metadata.Edm.MetadataCache+StoreMetadataEntry, System.Data.Entity]]
            ->  000000028076ca08 System.Collections.Generic.Dictionary2+Entry[[System.String, mscorlib],[System.Data.Metadata.Edm.MetadataCache+StoreMetadataEntry, System.Data.Entity]][]
            ->  000000028076c970 System.Data.Metadata.Edm.MetadataCache+StoreMetadataEntry
            ->  00000001808b2b70 System.Data.Mapping.StorageMappingItemCollection
            ->  000000028076ca68 System.Data.Metadata.Edm.StoreItemCollection
            ->  0000000280b07428 System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Collections.ObjectModel.ReadOnlyCollection1[[System.Data.Metadata.Edm.EdmFunction, System.Data.Entity]], mscorlib]]
            ->  0000000280b0b8b8 System.Collections.Generic.Dictionary2+Entry[[System.String, mscorlib],[System.Collections.ObjectModel.ReadOnlyCollection1[[System.Data.Metadata.Edm.EdmFunction, System.Data.Entity]], mscorlib]][]

Found 1 unique roots (run '!GCRoot -all' to see all roots).

0:025> !threads The version of SOS does not match the version of CLR you are debugging. Please load the matching version of SOS for the version of CLR you are debugging. CLR Version: 4.0.30319.18444 SOS Version: 4.0.30319.34011 ThreadCount: 17 UnstartedThread: 0 BackgroundThread: 17 PendingThread: 0 DeadThread: 0 Hosted Runtime: no Lock
ID OSID ThreadOBJ State GC Mode GC Alloc Context Domain Count Apt Exception 7 1 18c0 00000000017ef3d0 28220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 Ukn 18 2 1b2c 000000000293ddf0 2b220 Preemptive 00000001815883A0:000000018158A328 0000000001789fc0 0 MTA (Finalizer) 19 3 f60 0000000002991d30 102a220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 MTA (Threadpool Worker) 20 4 5b4 0000000002997ec0 21220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 Ukn 22 7 1748 0000000002a25f50 1020220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 Ukn (Threadpool Worker) 25 9 1d60 00000000090f1c20 202b220 Preemptive 00000002816ECE90:00000002816EECF8 000000000299f110 1 MTA 26 6 8d0 0000000002abf6e0 21220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 Ukn 27 12 1e5c 0000000009174120 21220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 Ukn 28 13 1968 00000000091b65b0 1029220 Preemptive 000000018287F518:0000000182881310 0000000001789fc0 0 MTA (Threadpool Worker) 29 11 e34 0000000002ade2b0 1029220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 MTA (Threadpool Worker) 30 15 640 0000000009175fe0 8029220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 MTA (Threadpool Completion Port) 31 18 b18 00000000091c1600 1029220 Preemptive 00000002824B8608:00000002824B8BA8 0000000001789fc0 0 MTA (Threadpool Worker) 43 5 1fe8 00000000091be5d0 20220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 Ukn 45 20 1c7c 00000000091beda0 1029220 Preemptive 00000001826F9BA8:00000001826F9D98 0000000001789fc0 0 MTA (Threadpool Worker) 48 14 ecc 00000000091bde00 1029220 Preemptive 0000000281874260:0000000281874270 0000000001789fc0 0 MTA (Threadpool Worker) 53 19 1498 00000000091bd630 1029220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 MTA (Threadpool Worker) 44 17 e38 00000000091bf570 20220 Preemptive 0000000000000000:0000000000000000 0000000001789fc0 0 Ukn

0:025> !clrstack The version of SOS does not match the version of CLR you are debugging. Please load the matching version of SOS for the version of CLR you are debugging. CLR Version: 4.0.30319.18444 SOS Version: 4.0.30319.34011 OS Thread Id: 0x1d60 (25) Child SP IP Call Site 00000000099fe848 000000007791186a [HelperMethodFrame_1OBJ: 00000000099fe848] System.Threading.WaitHandle.WaitMultiple(System.Threading.WaitHandle[], Int32, Boolean, Boolean) 00000000099fe980 000007fef830c64c System.Threading.WaitHandle.WaitAny(System.Threading.WaitHandle[], Int32, Boolean) 00000000099fe9e0 000007fef72b9376 System.Net.TimerThread.ThreadProc() 00000000099feab0 000007fef83bd0b5 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 00000000099fec10 000007fef83bce19 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 00000000099fec40 000007fef83bcdd7 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 00000000099fec90 000007fef8330301 System.Threading.ThreadHelper.ThreadStart() 00000000099fefa8 000007fef9599e03 [GCFrame: 00000000099fefa8] 00000000099ff2d8 000007fef9599e03 [DebuggerU2MCatchHandlerFrame: 00000000099ff2d8] 00000000099ff4b8 000007fef9599e03 [ContextTransitionFrame: 00000000099ff4b8] 00000000099ff6a8 000007fef9599e03 [DebuggerU2MCatchHandlerFrame: 00000000099ff6a8]

2 个答案:

答案 0 :(得分:5)

正如我在评论中所说,您应该更新版本以便CLR和SOS匹配,否则您可能会看到不正确的输出。

堆栈只显示该对象由r12中的代码使用的寄存器(在本例中为ThreadProc())生根。回想一下,对象可以通过以下方式生根:

  • 堆叠/寄存器
  • GC Handle
  • 终结者队列
  • 上述任何一项中发现的物体的成员

答案 1 :(得分:0)

您可以使用'.chain'命令来显示已加载的DLL。然后你可以使用'.unload path'来卸载除非DLL,然后重新加载匹配DLL你将解决这个问题。关于如何获取匹配DLL,您可以检查目标机器路径'%windir%\ microsoft.net \ framework \< .NET version>'那么你可以得到匹配的DLL