确定待定终结器源

发布于 2024-12-07 14:09:07 字数 473 浏览 0 评论 0 原文

我正在参与一个存在已知问题的项目。应用程序因调用 GC.WaitForPendingFinalizers 而挂起。明显的解决方法是删除 WaitForPendingFinalizers 调用,但不幸的是,这是在第三方程序集中为我们完成的,因此删除不是一个选项。

相反,我想找到问题的根源并找出谁的终结器正在阻塞。然而,代码库很大,而且由于我刚刚接触它,所以它也不熟悉,所以我什至对它可能在哪里没有任何直觉或直觉。这意味着我需要使用仪器和工具来帮助找到它。

所以我的问题是:

  1. 迭代 Finalizer 队列的框架/ee 线程是否会显示在 Studio 的线程视图中?堆栈跟踪对于找到我们挂在哪里有很大帮助。
  2. 是否有一个工具可以向我显示待处理的终结器及其根源(这是一个 CF 项目,但我愿意采取广泛的途径来尝试找到它)?
  3. 任何人有任何想法或经验想要分享,可能有助于找到这个?

I'm coming into a project that has a known issue. The application hangs on a call to GC.WaitForPendingFinalizers. The obvious solution workaround is to remove the WaitForPendingFinalizers call but unfortunately this is being done for us in a third-party assembly, so removal is not an option.

Instead, I want to find the root of the issue and figure out who's finalizer is blocking. The codebase, however, is large and since I'm just coming into it, it's also unfamiliar so I don't even have any gut feelings or intuitions of where it might be. This means I'm going to need to use intrumentation and tools to help find it.

So my questions are:

  1. Will the framework/ee thread that is iterating the Finalizer Queue show up in the Threads view in Studio? The stack trace for this would go a long way to finding where we are hanging.
  2. Is there a tool that will show me pending finalizers and their roots (this is a CF project, but I'm willing to take wide paths to try and find this)?
  3. Anyone have any thoughts or experiences they want to share that might aid in finding this?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心凉怎暖 2024-12-14 14:09:07

我快速浏览了 VS (VS 11),当我中断时,我可以看到一个名为“GC Finalizer Thread”的线程,并且它在我的析构函数中执行 Sleep() 操作。

但你提到的 CF 可能会让它变得完全不同。

I took a quick look in VS (VS 11) and when I break I can see a Thread called "GC Finalizer Thread" and it's caught doing a Sleep() in my destructor.

But your mention of CF may make it an entirely different ballgame.

囍孤女 2024-12-14 14:09:07

这可能是 Windbg 成为您朋友的情况之一。看看苔丝的博客。这是一篇有关使用 !finalizequeue 调试器命令调试终结器问题的文章。 http://blogs.msdn.com/b/tess/archive/2007/10/19/net-finalizer-memory-leak-debugging-with-sos-dll-in-visual-studio。 aspx

(如果您以前从未使用过 Windbg 和 sos.dll,请在 Tess 的博客上多阅读一些内容。她的一些文章使其非常平易近人)。

This might be one of those cases where Windbg is your friend. Have a look at Tess's blog. Here's an article about debugging a finalizer issue with the !finalizequeue debugger command. http://blogs.msdn.com/b/tess/archive/2007/10/19/net-finalizer-memory-leak-debugging-with-sos-dll-in-visual-studio.aspx

(If you've never done anything with windbg and sos.dll before, do some more reading on Tess's blog. She has some articles that make it very approachable).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文