RE: An observation about "live" NodeLists

Arnaud Le Hors wrote,
> keshlam@us.ibm.com wrote:
> > Since Java's GC-based, making the Nodes aware of the 
> > NodeLists means the NodeList objects have to persist
> > as long as the Nodes they're based on do; there's no 
> > architected way to tell the DOM that they're no longer
> > needed.
> 
> I know we can't rely on this yet but the WeakReferences
> in Java 1.2 will greatly help address this problem.

Sadly not ... even with 1.2 weak refs we still have no
guarantees on how soon we will be notified that an object
has only weak refs to it. Basically the situation is
much the same as it is with finalize() ... the only
difference is that the strong ref/strong ref cycle that
JK is worrying about (because it prevents GC) can be
broken by replacing it with a strong ref/weak ref cycle
(which will allow GC). But we're still at the mercy of
the indeterminacies of Java GC.

There is, in any case, a way of dealing with the cycle
that gets you just as much/little as weak refs, but is
fine with Java 1.1 ... hint, try a combination of the
handle-body idiom with finalize().

Err ... I can elaborate on that if it's not too far off
topic for this list ...

Cheers,


Miles

-- 
Miles Sabin                          Cromwell Media
Internet Systems Architect           5/6 Glenthorne Mews
+44 (0)181 410 2230                  London, W6 0LJ
msabin@cromwellmedia.co.uk           England

Received on Tuesday, 20 October 1998 10:54:12 UTC