Actually it would be more like:
function destroy(o){
    for(var i in o){
      if(typeof o[i]=="object") destroy(o[i])
      delete o[i]
    }
    o=null
  }   

But I've tried creating and destroying a lot of nested 
objects, and just using blank pages, and I get basically 
the same result = IE5 always steals about 100 k, no matter 
what.
However , 100k is alot better than 2 megs. So the destroy 
method might help in those cases.
Try it out.

> (might have double posted this.. sorry ;))
> 
> hmm.... I wonder if this is still true... that garbage 
> collection is done by reference counting...
> This would be very wierd since there are circular 
> references already in host objects! (Like subobjects of 
> window that point back at window.)
> But.. this would explain IE:s general memory leak I guess.
> I wonder if delete solves this problem?
> At any rate, the destroy method would have to be 
recursive, 
> i.e something like:
> 
> function destroy(obj){
>   for(var i in obj)
>     if(typeof obj[i]=="object") destroy(obj[i])
>   delete obj
> }
> 
> 
> > 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
> > 
> 
> 
> 
> _______________________________________________
> Dynapi-Dev mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/dynapi-dev
> 



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

Reply via email to