Sounds like we need a "null cycle killer".  Damn sure circular references a
playing a big roll in our leak...

>

This problem with cycles is the price that must be paid for a simple,
lightweight, portable garbage collection scheme. The only way to prevent
this problem is by manual intervention. If you create code in which A refers
to B, B refers to C, and C refers to A, then you must be able to recognize
that you've created a cycle, and take steps to force the cycle to be garbage
collected when it is no longer needed.

When you know that the objects in your cycle are no longer in use, you can
force them to be garbage collected by breaking the cycle. You can do this by
picking one of the objects in the cycle and setting the property of it that
refers to the next object to null. For example, suppose that A, B, and C are
objects that each have a next property, and the value of this property is
set so that these objects refer to each other and form a cycle. When these
objects are no longer in use, you can break the cycle by setting A.next to
null. This means that object B no longer has a reference from A, so its
reference count can drop to zero and it can be garbage collected. Once it
has been garbage collected, then it will no longer refer to C, so its
reference count can drop to zero and it can be garbage collected. Once C is
garbage collected, A can be garbage collected.

Note, of course, that none of this can happen if A, B, and C are stored in
global variables in a window that is still open, because those variables A,
B, and C still refer to the objects. If these were local variables in a
function, and you broke their cycle before the function returned, then they
could be garbage collected. But if they are stored in global variables, they
will remain referenced until the window that contains them closes. In this
case, if you want to force them to be garbage collected you must break the
cycle and set the variables to null:


A.next = null;      // break the cycle
A = B = C = null;   // remove the last remaining external references




_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev

Reply via email to