Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have not run an explict garbage collection. From the docs of <a href="http://msdn.microsoft.com/en-us/library/xe0c2357%28VS.80%29.aspx" rel="nofollow noreferrer">GC.Collect()</a>:</p> <blockquote> <p>Use this method to attempt to reclaim all memory that is inaccessible. However, the Collect method does not guarantee that all inaccessible memory is reclaimed.</p> <p>All objects, regardless of how long they have been in memory, are considered for collection; however, objects that are referenced in managed code are not collected. Use this method to force the system to attempt to reclaim the maximum amount of available memory.</p> </blockquote> <p>The garabage collector is highly optimized and "decides" all by himself when he actually does the garbage collection and then call the finalizers. Additionally it is all done asynchronously. That is also why Finalizers are called non-deterministic cleanup. You never now when cleanup happens.</p> <p>You have two options now. You can either call <a href="http://msdn.microsoft.com/en-us/library/system.gc.waitforpendingfinalizers.aspx" rel="nofollow noreferrer">GC.WaitForPendingFinalizers()</a> wich will halt the current thread until the all finalizable objects have been finalized. Or call this new overload: <a href="http://msdn.microsoft.com/en-us/library/bb356724%28VS.90%29.aspx" rel="nofollow noreferrer">System.GC.Collect(int generation, System.GCCollectionMode mode)</a> with <code>GCCollectionMode.Forced</code> It was introduced in .NET 3.5.</p> <p>Just keep in mind that usually it is not necessary and more importantly: <strong>a bad idea</strong> to call the garbage collector manually. Also implementing the finalizer is only needed in rare occasions. Calling the garbage collector will slow down the runtime. Implementing finalizers will slow down the runtime additionally. The garabge collector puts all objects that implement the finalizer into the finalization queue when they are ready to be garabge collected. Processing this queue is expensive. To make things worse, when the finalizer is run, it is not guaranteed that the members you are trying to access there are still alive. It is very well possible they have already been grabage collected. That's why you should use the finalizer only when you have <strong><em>unmanaged</em></strong> resources that need to be cleaned up.</p> <p>All this is definately not needed in your example. What you acutally want is <a href="http://msdn.microsoft.com/en-us/library/system.idisposable.aspx" rel="nofollow noreferrer">IDisposable</a> for deterministic cleanup.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload