Friday, May 29, 2009

How to find the thread which triggered a GC

How to find the thread which triggered a GC

1. Take a memory dump of the application at the correct time ( The time its using high CPU)
2. Run ~* kb 2000 to get all native stacks
3. Search for mscorwks!SVR::GCHeap::GarbageCollectGeneration, its the thread that triggered the GC ()

In addition you can see if a thread is blocked as a result of GC call by searching GCHeap::WaitUntilGCComplete

OS Thread Id: 0xcf4 (37)
Current frame: ntdll!KiFastSystemCallRet
ChildEBP RetAddr Caller,Callee
1a2ee3e4 7c90e9c0 ntdll!ZwWaitForSingleObject+0xc
1a2ee3e8 7c8025db kernel32!WaitForSingleObjectEx+0xa8, calling ntdll!NtWaitForSingleObject
1a2ee43c 7c8399f3 kernel32!_except_handler3
1a2ee44c 79e77fd1 mscorwks!PEImage::LoadImage+0x199
1a2ee490 79e77f9a mscorwks!CLREvent::WaitEx+0x117, calling mscorwks!PEImage::LoadImage+0x16a
1a2ee4b0 79f8eb00 mscorwks!WaitForMultipleObjectsEx_SO_TOLERANT+0x165, calling ntdll!RtlSetLastWin32Error
1a2ee4b4 79f8eb08 mscorwks!WaitForMultipleObjectsEx_SO_TOLERANT+0x16d, calling mscorwks!_SEH_epilog4
1a2ee4e0 79e77f50 mscorwks!CLREvent::Wait+0x17, calling mscorwks!CLREvent::WaitEx
1a2ee4f0 79f762f7 mscorwks!WKS::GCHeap::WaitUntilGCComplete+0x32, calling mscorwks!CLREvent::Wait
1a2ee500 79f75d6a mscorwks!Thread::RareDisablePreemptiveGC+0x1a1

No comments:

Post a Comment