[jdom-interest] Hello

Laurent Bihanic laurent.bihanic at atosorigin.com
Tue Feb 25 01:08:19 PST 2003


Hi,

Mike Brenner wrote:
> The web service leads to a question. Is it a developer's responsibility
> to remove all the children from the root node of each DOCUMENT we parse?
> There does not seem to be an API that deletes the children to 
> prevent memory leakages in cases where the root node is passed
> to another procedure. (Unless finalize does that?)

There is no need for such a method. Node children get garbage-collected when 
the node (document, root node...) itself is garbage collected.
Why should passing a node as argument to a method would require deleting its 
children? These children are part of the document and probably contain 
valuable information.

> The web service seems to have a memory leakage that goes away when
> a procedure is run against each root node of each document,
> to delete all the children of those root nodes.

The problem is probably not in JDOM. Check your code, your are probably 
keeping a reference to the document, the root node or any other node 
somewhere. As nodes reference each others in JDOM, keeping a reference to a 
single node in a document means the whole document won't be garbage-collected.

Deleting the root node children just lessen the amount of memory leaked so 
that you may think there is no more leak. Probably the document and the root 
node are still referenced somewhere, resulting in a smaller leak.

Laurent




More information about the jdom-interest mailing list