Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First off, the GC isn't under anyone's direct control but the runtime's; it will run only when the runtime thinks it should. That means that objects scheduled for cleanup may persist for seconds or even minutes until the memory conditions indicate a cleanup should be performed.</p> <p>However, 10,000 dead instances waiting to be cleaned up sounds like a memory leak. Some things to check:</p> <p>Does oVariable contain or reference an unmanaged or IDisposable object? If so, oVariable should implement IDisposable and perform cleanup, releasing references to objects it does not "own", and/or disposing of objects it does control. There is a pattern you can use to avoid having to call Dispose() explicitly; look at <a href="http://www.codeproject.com/KB/cs/idisposable.aspx" rel="nofollow">http://www.codeproject.com/KB/cs/idisposable.aspx</a>.</p> <p>Does oVariable subscribe to any events of other objects? As long as the object with the event is in memory, any oVariable that has added its handler to the event will remain in memory, because the reference to the method will keep the object "alive" as far as GC is concerned. Again, you should create an IDisposable implementation and have the object remove itself from any events it listens to.</p> <p>Lastly, I noticed in your comment to another post that you maintain hierarchical relationships, both upwards and downwards, to other oVariables. As long as an oVariable is in any of those lists, it's referenced. I would triple-check all code that adds and removes instances from these lists; you're forgetting to remove objects somewhere, so they hang around indefinitely. Again, disposing of an oVariable should involve (1) removing any reference to the variable as a Slave from any/all Master oVariables, (2) removing any reference to the variable as a Master from any/all of the Slaves, and finally (3) clearing the variable's Master and Slave lists. Only once the object is completely "orphaned" in memory will GC destroy it.</p>
 

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