Thanks.  In the case of Node.createClone(), I could see how
back-pointers could be a problem (although I think the documentation
says everything should be a copy when the clone is complete.).  However,
for Document.newElement(), assuming we don't use setUserData() or
similar methods, are there any back pointers to other nodes in the
document?

 

From: Michael Glavassevich [mailto:mrgla...@ca.ibm.com] 
Sent: Wednesday, April 22, 2009 8:49 AM
To: j-users@xerces.apache.org
Subject: Re: Node without parent eligible for garbage collection or
pinned by Document?

 

Hi Gary,

They will usually be eligible for garbage collection, however there are
some operations (e.g. setUserData()) which will pin down the memory even
if the Node is otherwise orphaned. Basically there are a bunch of
structures in the Document node impl which might have back-pointers to
other nodes in the document that can't be cleared until the application
no longer has any references to those nodes. Future versions of Xerces
will use SoftReferences and WeakReferences in these places so such nodes
can be garbage collected earlier.

Thanks.

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

"Gary Hirschhorn" <ghirschh...@fetch.com> wrote on 04/22/2009 11:34:46
AM:

> If I create new Nodes via Node.createClone() or Document.
> newElement(), I now have a Node that belongs to a Document, but has 
> no parent Node. With regards to garbage collection, if this new Node
> is no longer reachable by the objects in my code, is it eligible for
> garbage collection, or is there some internal pointer from Document 
> that will pin this Node in memory until the Document is garbage
collected?  
>  
> Thanks,
> Gary

Reply via email to