When does GC decide to collect generation 2?
.net, garbage-collection
Solution
Read http://msdn.microsoft.com/en-us/library/0xy59wtx.aspx and the linked articles for more information. In general, gen2 is collected "when necessary."
One thing that can cause excessive Gen2 collections is the large object heap (LOH). When the LOH gets filled, it will trigger a full collection. If your application allocates and frees lots of large objects (80K or larger), that could very well be your problem.
See CLR Inside Out: Large Object Heap Uncovered.
Also consider using the server garbage collector in your service. It will typically provide better performance (fewer collections). Add this to your app.config file:
<configuration
<runtime>
<gcServer enabled="true"/>
</runtime>
</configuration>
Problem
During the day I see a lot of gen 2 collections in our windows service. When does GC decide to do full collection instead of collecting only Gen1 and Gen0 or only Gen0?