title: Garbage collection Guarantees
body: <p>What guarantees are the for the garbage collector?</p>
  
  <p>From my research I have managed to find:</p>
  
  <ul>
  <li>If there is still a reference to the memory it will not be garbage collected</li>
  <li>If there is no reference:
  
  <ul>
  <li>When it is GC is non deterministic</li>
  <li>When the GC kicks in the finalizer will be run before memory is released.</li>
  <li>There is no guarantee about the order of Finalizers (so do not assume parent will be run before child).</li>
  </ul></li>
  </ul>
  
  <p>But what I really want to know is:</p>
  
  <p>Is there a guarantee that all memory will eventually be garbage collected and the finalizer (destructor) run on the object (assuming the program exited nicely). For example an application with no memory pressure when it eventually exits will it force the GC to go find all objects and make sure the finalizer (destructor) is called (including static member variables)?</p>
  
  <p>I did find a quote on this page:
      <a href="http://www.c-sharpcorner.com/UploadFile/tkagarwal/MemoryManagementInNet11232005064832AM/MemoryManagementInNet.aspx" rel="noreferrer">http://www.c-sharpcorner.com/UploadFile/tkagarwal/MemoryManagementInNet11232005064832AM/MemoryManagementInNet.aspx</a></p>
  
  <blockquote>
    <p>In addition, by default, Finalize methods are not called for unreachable objects when an application exits so that the application may terminate quickly.</p>
  </blockquote>
  
  <p>But I am not sure how authoritative this quote is.</p>
  
  <p>I also found documentation on:
     <a href="http://msdn.microsoft.com/en-us/library/system.runtime.constrainedexecution.criticalfinalizerobject.aspx" rel="noreferrer">CriticalFinalizerObject</a></p>