Question regarding GC  
Author Message
Debabrata.debroy





PostPosted: Common Language Runtime, Question regarding GC Top

I want to know when gc starts its working.I mean after de execuation of any application or like some interval.

Thanx in advance



.NET Development4  
 
 
Nikhil Rajwade





PostPosted: Common Language Runtime, Question regarding GC Top

The GC is called everytime the gen-0/managed heap is full. But that will not necessarily 'release' memory or reduce a processes working set.

The finalizers on objects are called when

1) gen-0 is full.

2) System.GC.Collect() is called (Bad practice!!)

3) The Win32 CreateMemoryResourceNotification and QueryMemoryResourceNotification functions monitor system memory overall. If these report a low memory situation, the CLR may force a GC collect to free dead objects.

4) the clr is unloading an AppDomain

5) the CLR is shutting down (not same as process shutting down).

In v2.0, GC collections are no longer forced on AppDomain unload, but finalizers are still automatically run. (Many thanks to Chris Lyon for that one!)



 
 
Chris Lyon - MS





PostPosted: Common Language Runtime, Question regarding GC Top

This blog entry gives details on when the GC performs collections:

http://blogs.msdn.com/maoni/archive/2004/06/15/156626.aspx

1) Allocation exceeds the Gen0 threshold
2) System.GC.Collect is called
3) System is in low memory situation

Hope that helps

-Chris