Identifying Pending Finalizer Sources

I come to a project that has a known issue. Application freezes when calling GC.WaitForPendingFinalizers . The obvious solution is to remove the WaitForPendingFinalizers call, but unfortunately this is done for us in a third-party assembly, so removing is not an option.

Instead, I want to find the root of the problem and find out who the finalizer is blocking. The code base, however, is large, and since I just enter it, it is also unfamiliar, so I don’t even have any feelings or intuitions about where it can be. This means that I will need to use tools and search tools.

So my questions are:

  • Will the framework / ee thread that iterates the Finalizer queue show up in the Threads view in Studio? A stack trace for this would go a long way to find where we are hanging.
  • Is there a tool that will show me the pending finalizers and their roots (this is a CF project, but I am ready to take wide paths to try and find this)?
  • Does anyone have any thoughts or experiences that they want to share that can help find this?
+4
source share
2 answers

I quickly looked through VS (VS 11), and when I break, I see a thread called "Thread Finalizer GC" and it caught the Sleep () call in my destructor.

But your mention of CF can make it a completely different ball.

+1
source

This may be one of the cases where Windbg is your friend. Take a look at Tess's blog. Here's an article about debugging a finalizer with a team! Finalizequeue debugger. 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, do some more reading on the Tess blog. She has articles that make it very accessible).

+1
source

All Articles