如何快速获取使用大量 CPU 的线程的托管堆栈跟踪

发布于 2024-12-19 04:54:15 字数 352 浏览 4 评论 0原文

在诊断高 CPU 问题时,首先想到的问题是哪个线程正在使用所有 CPU 以及它在做什么(用托管代码术语来说)?为了解决这个问题,需要安装 Process Explorer 来查找有问题的线程。然后,需要捕获进程的转储,将其加载到像 Windbg 这样的东西中,并找出线程正在做什么 - 找出每个线程的托管堆栈跟踪。

这个过程有点耗时。是否有一种工具(免费或付费)或可以编写的可靠代码,可以在几秒钟内完成所有这一切(单击按钮)。我希望看到的最终结果是按 CPU 利用率排序的线程列表以及它所在的当前方法,并可以选择向下钻取以查看整个堆栈跟踪。除了托管代码之外,基本上与您在 Process Explorer 中看到的内容相同。

这需要适用于 .NET 4.0。

When diagnosing a high CPU issue, the first question that comes to mind is which thread(s) is using all the CPU and what is it doing (in Managed Code terms)? To figure this out one needs to install Process Explorer for example to find the offending thread. Then one needs to capture a dump of the process, load it in something like windbg and find out what the thread(s) are doing - find out the managed stack trace of each thread.

This process is somewhat time consuming. Is there a tool (free or for pay), or reliable code that could be written, that could do all this in a matter of seconds (click of a button). The end result I'd like to see is a list of threads ordered by CPU utilization and the current method it is in with the option to drill down to see the whole stack trace. Basically the same thing you'd see in Process Explorer except for managed code.

This would need to work for .NET 4.0.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文