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:
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).
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.