Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何诊断是什么阻止死线程在.NET中被回收_.net_Windbg - Fatal编程技术网

如何诊断是什么阻止死线程在.NET中被回收

如何诊断是什么阻止死线程在.NET中被回收,.net,windbg,.net,Windbg,自托管的C#ASP.NET WEB.API应用程序在生产中停止响应HTTP GET/POST操作。我有一个从生产服务器获取的内存转储。dmp中唯一不寻常的事情是死线程的数量相对较高 被截断的!线程输出: 0:000> !Threads ThreadCount: 116 UnstartedThread: 0 BackgroundThread: 5 PendingThread: 0 DeadThread: 110 Hosted Runtime: no XXXX

自托管的C#ASP.NET WEB.API应用程序在生产中停止响应HTTP GET/POST操作。我有一个从生产服务器获取的内存转储。dmp中唯一不寻常的事情是死线程的数量相对较高

被截断的
!线程
输出:

0:000> !Threads
ThreadCount:      116
UnstartedThread:  0
BackgroundThread: 5
PendingThread:    0
DeadThread:       110
Hosted Runtime:   no
XXXX   2d       04b87ca0   1019820 Enabled  00000000:00000000 0015e800     0 Ukn (Threadpool Worker)
XXXX   2e       04b87390   1019820 Enabled  00000000:00000000 0015e800     0 Ukn (Threadpool Worker)
XXXX   55       04b86a80   1019820 Enabled  00000000:00000000 0015e800     0 Ukn (Threadpool Worker)
XXXX   53       04b86188   1019820 Enabled  00000000:00000000 0015e800     0 MTA (Threadpool Worker)
XXXX   54       04b858a8   1019820 Enabled  00000000:00000000 0015e800     0 MTA (Threadpool Worker)
该应用程序有121个
System.Threading.Thread
对象:

0:000> !dumpheap -stat -type System.Threading.Thread
total 0 objects
Statistics:
      MT    Count    TotalSize Class Name
79b59b8c        1           20 System.Threading.ThreadHelper
79b9297c        2           64 System.Threading.ThreadStart
79b9ff90        2          168 System.Threading.ThreadAbortException
79ba0128      121         5808 System.Threading.Thread
Total 126 objects
查看一些线程,似乎没有任何引用使它们保持活动状态。示例线程:

0:000> !do 051c5578 
Name:        System.Threading.Thread
MethodTable: 79ba0128
EEClass:     798d8ed8
Size:        48(0x30) bytes
File:        C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
Fields:
      MT    Field   Offset                 Type VT     Attr    Value Name
79b88b84  400077f        4 ....Contexts.Context  0 instance 00000000 m_Context
79b9b5c4  4000780        8 ....ExecutionContext  0 instance 00000000 m_ExecutionContext
79b9fb08  4000781        c        System.String  0 instance 00000000 m_Name
79b9ffdc  4000782       10      System.Delegate  0 instance 00000000 m_Delegate
79ba6500  4000783       14 ...ation.CultureInfo  0 instance 00000000 m_CurrentCulture
79ba6500  4000784       18 ...ation.CultureInfo  0 instance 00000000 m_CurrentUICulture
79b9f744  4000785       1c        System.Object  0 instance 00000000 m_ThreadStartArg
79b9ab88  4000786       20        System.IntPtr  1 instance  4b77aa0 DONT_USE_InternalThread
79ba2ad4  4000787       24         System.Int32  1 instance        2 m_Priority
79ba2ad4  4000788       28         System.Int32  1 instance        8 m_ManagedThreadId
79b8b878  4000789      18c ...LocalDataStoreMgr  0   shared   static s_LocalDataStoreMgr
    >> Domain:Value  0015e800:NotInit  <<
79b8e434  400078a        c ...alDataStoreHolder  0   shared TLstatic s_LocalDataStore
    >> Thread:Value <<

如何继续诊断以找出导致此问题的原因?

这对您有用吗?121个线程不挂起web服务器。这很可能只是该计划其他问题的副作用。我们后来发现,同一台服务器上的不同服务占用了100%的CPU。解决了贪婪的服务后,我们有问题的服务似乎恢复了正常。也就是说,我很想了解这里发生了什么。@Jason-我之前在谷歌上搜索时发现了这篇文章。这是有用的,但在我的例子中,没有任何明显的根来保持
线程
对象的活动。
0:000> !gcroot 051c5578
Note: Roots found on stacks may be false positives. Run "!help gcroot" for
more info.
Scan Thread 0 OSTHread 590
Scan Thread 2 OSTHread 1510
Scan Thread 3 OSTHread c24
Scan Thread 5 OSTHread 14f8
Scan Thread 8 OSTHread 1d48
Scan Thread 9 OSTHread 1e4c