简体   繁体   English

确定待定的终结器源

[英]Determining Pending Finalizer Sources

I'm coming into a project that has a known issue. 我正在参加一个存在已知问题的项目。 The application hangs on a call to GC.WaitForPendingFinalizers . 该应用程序挂在对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. 显而易见的 解决 方案是删除WaitForPendingFinalizers调用,但不幸的是,此操作已在第三方程序集中为我们完成,因此无法删除。

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? 会在Studio的“线程”视图中显示正在迭代Finalizer队列的Framework / ee线程吗? 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)? 有没有一种工具可以向我显示即将完成的终结器及其根源(这是一个CF项目,但我愿意走宽的道路来尝试找到它)?
  3. Anyone have any thoughts or experiences they want to share that might aid in finding this? 是否有任何他们想分享的想法或经验可以帮助您找到答案?

This might be one of those cases where Windbg is your friend. 这可能是Windbg是您的朋友的情况之一。 Have a look at Tess's blog. 看看Tess的博客。 Here's an article about debugging a finalizer issue with the !finalizequeue debugger command. 这是有关使用!finalizequeue调试器命令调试终结器问题的文章。 http://blogs.msdn.com/b/tess/archive/2007/10/19/net-finalizer-memory-leak-debugging-with-sos-dll-in-visual-studio.aspx 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). (如果您以前从未使用windbg和sos.dll进行过任何操作,请在Tess的博客上进行更多阅读。她提供了一些文章,使其很容易上手)。

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. 我快速浏览了VS(VS 11),当我中断时,我可以看到一个名为“ GC Finalizer Thread”的线程,并且在析构函数中执行Sleep()被捕获。

But your mention of CF may make it an entirely different ballgame. 但是您对CF的提及可能会使它完全不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM