为什么报道的WinDbg的线程数,任务管理器和VS调试器有什么区别? [英] Why does the number of threads reported by WinDbg, Task Manager and VS Debugger differ?

查看:419
本文介绍了为什么报道的WinDbg的线程数,任务管理器和VS调试器有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我的。NET 3.5的应用程序正在运行,Windows任务管理器显示我的应用程序有16个线程。我收集过程中的内存转储和使用的WinDbg / SOS打开了它。

While my .Net 3.5 app was running, the Windows Task Manager shown that my app had 16 threads. I collected a memory dump for the process and opened it using WinDbg/SOS.

运行线程命令表明我有:

Running the !threads command reveals that I have :

ThreadCount: 456
UnstartedThread: 0
BackgroundThread: 6
PendingThread: 0
DeadThread: 449
Hosted Runtime: no

下面是对前几行线程输出:

Here are the first few lines of the !threads output:


       ID OSID ThreadOBJ    State     GC       Context       Domain   Count APT Exception
   0    1 2848 004366a8      6020 Enabled  11738178:11738778 0042a9f0     0 STA
   2    2 1820 004430e0      b220 Enabled  00000000:00000000 0042a9f0     0 MTA (Finalizer)
   7    5 2c38 055d6330    80a220 Enabled  00000000:00000000 0042a9f0     0 MTA (Threadpool Completion Port)
   8    4  e18 04116900   180b220 Enabled  1157cdc8:1157e778 0042a9f0     0 MTA (Threadpool Worker)
XXXX    6    0 055f94b0      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX    7    0 05649228      9820 Enabled  00000000:00000000 0042a9f0     0 MTA
XXXX    8    0 0567d4f8      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX    9    0 05688d68      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX    a    0 056fd680      9820 Enabled  00000000:00000000 0042a9f0     0 MTA
XXXX    b    0 0575d7f0      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX    c    0 056fd250      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX    d    0 0572a780      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX    e    0 0f082668      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX    f    0 0f082a38      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   10    0 0570ca68      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   11    0 0570ce50      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
  10   12 3fb0 0570d238   180b220 Enabled  00000000:00000000 0042a9f0     0 MTA (Threadpool Worker)
XXXX   13    0 0570d620      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   14    0 0570da08      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   15    0 0570ddf0      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   16    0 0570e1d8      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   17    0 0570e5c0      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   18    0 0579e540      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   19    0 0579e928      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   1a    0 0579ed10      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   1b    0 0579f0f8      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   1c    0 0579f4e0      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   1d    0 0579f8c8      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   1e    0 0579fcb0      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   1f    0 057a0098      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn
XXXX   20    0 057a0480      9820 Enabled  00000000:00000000 0042a9f0     0 Ukn

如果我附上了Visual Studio调试到正在运行的进程,线程窗口显示7线程。

If I attach the Visual Studio Debugger to the running process, the Threads windows shows 7 threads.

我有几个问题:

  • 为什么WinDbg中说,有456线程和任务管理器中说,16
  • 为什么任务管理器中说,有16个线程和Visual Studio调试器说,7
  • 的!线程命令显示,所有那些死去的线程没有OSID值。这是否意味着他们不再是已知的OS是,只是说是布局围绕.NET对象?什么是死的线程是什么呢?
  • 我应该担心大量死亡线程?

修改2010年2月11日:以下是关于我的应用程序的更多信息。我们使用后台线程轮询服务器,并执行其他任务。这些任务的执行中每隔几分钟。我们不使用.NET线程池。

EDIT Feb 11th 2010: Here is more information about my app. We use background threads to poll the server and perform other tasks. Those tasks are executed every few minutes. We do not use the .Net Thread Pool.

修改2010年2月18日:我定格在我们的节目的管理Thread对象泄漏(感谢@highphilosopher)。但是,我为什么WinDbg中,任务管理器和VS调试器不同意的线程数量问题仍然是悬而未决。谁能解释?

EDIT Feb 18th 2010: I fixed the managed Thread object leak in our program (thanks to @highphilosopher). However, my question about why WinDbg, Task Manager and VS Debugger don't agree on the number of threads is still unanswered. Can anyone explain?

修改2010年3月1日:我仍然有兴趣知道为什么任务管理器和Visual Studio调试不同意线程数。为什么Visual Studio中筛选一些线程?什么样的线程它过滤掉?

EDIT Mar 1st 2010: I'm still interested in knowing why Task Manager and Visual Studio Debugger don't agree on the number of threads. Why does Visual studio filter some of the threads? What kind of threads does it filter out?

推荐答案

任务管理器报告的线程总数为你的过程,而!线程报告中的管理的主题。如果您在WinDbg中使用命令,你会看到所有线程的线程的过程。

Task manager reports the total number of threads for your process while !threads reports the number of managed threads. If you use the ~ command in WinDbg you will see all thread threads for the process.

输出!线程在输出显示很多死亡的线程。与 XXXX 的ID列出的线程都已经终止,但相应的线程对象尚未收集线程。即所报告的数量比实际的线程数目高得多。该线程数的数字指出,456线程449都死了。

The output from !threads in your output shows a lot of dead threads. The threads listed with XXXX for id are threads that have terminated but the corresponding thread objects have not yet been collected. I.e. the reported number is much higher than the actual number of threads. The thread count numbers state that 449 of the 456 threads are dead.

我觉得线程高的号码,如果应用程序已空闲奇怪的是the're仍然存在,但没有进一步的信息,很难更具体。

I find the number of threads high and if the application has been idle it is odd that the're still around, but without further info it is hard to be more specific.

这篇关于为什么报道的WinDbg的线程数,任务管理器和VS调试器有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆