views:

63

answers:

2

Hello,

I'm trying to debug a .net windows service that is spending lot of his time in GC.

Using windbg during collections I discovered that most of the time is spent in:

00000000`0279e8e0 00000642`7f5368a3 mscorwks!WKS::gc_heap::plan_phase+0x50c
00000000`0279ea90 00000642`7f94ef4e mscorwks!WKS::gc_heap::gc1+0x73
00000000`0279eae0 00000642`7f51c259 mscorwks!WKS::gc_heap::garbage_collect+0x29e
00000000`0279eb40 00000642`7f4eb56e mscorwks!WKS::GCHeap::GarbageCollectGeneration+0x199
00000000`0279ebd0 00000642`7f4ea49d mscorwks!WKS::gc_heap::try_allocate_more_space+0x38e
00000000`0279eca0 00000642`7f4e9cef mscorwks!WKS::GCHeap::Alloc+0x6d
00000000`0279ecd0 00000642`7f9b35da mscorwks!FastAllocateObject+0xaf

The pattern of Gen0,Gen1,Gen2 collections is reasonable (100,10,1)

Please note that the application runs on x64 and has a really large heap:

Gen0    10M
Gen1    26K
Gen2    4,371M
Large   3,500M

Note: I know about the great Tess Ferrandez blog.

A: 

I would hazard a guess that this is the GC's marking phase in which it identifies objects that have no roots and need to be collected. This is simply a guess as there does not seem to be much information about this (as I am sure you know).

Andrew Hare
+1  A: 

plan_phase is one of the phases the GC does. The GC has 2 phases 1- Mark phase : In this phase all the live (reachable objects ) are marked by following the roots to these objects, depending on collection type (Gen0,1 or 2 ), we mark certain part of the heap ( Gen0,1), or the whole heap (Gen 2 collections)

2- Plan phase : once we marked the live objects, we know certain things about the heap, things such as fragmentation and ration of live object compared to the heap size ..etc. During the plan phase, we decide what GC decision is best, should we do a compacting GC ( takes more time, but helps when you have high fragmented heap ), or should we do a sweeping decision ( very fast,just make a free list of objects ).

You have ~4GB Gen2 heap, this is a big heap and could take some time to collect it.
I am not sure when you mentioned "large time", what did you mean ( quantitative measures? ), is it 100ms, seconds, minutes?

mfawzymkh
Thanks for the good answer. About 5 sec. Should I consider the idea that my heap is fragmented? How do the GC decide to do a full gen2 collection instead of just gen0. All the data are loaded at process startup and don't change at all during the execution
Luca Martinetti