Flush DOM Document?

I have an application where I read in some XML via a socket, parse it from a string into an Element, process it, then spit it back out as XML. Each node is independent of each other. Right now, I have a Document in my reading thread that is shared for each node that comes in. The processing step can add considerable data to the node, then it is spit back out.

My problem is that huge amounts of memory are used and seem to stay around. I assume that the Document is holding on to each of these nodes, even though they are never put into the DOM hierarchy.

The question is: should I create a new Document for each node input? It seems like a potential performance hog. Is there some way of telling the document to release references to a Node?

Thanks!

[778 byte] By [jgouldinga] at [2007-10-3 3:35:17]
# 1

My guess would be that a Node contains a reference to the Document that contains it, but not vice versa. So your assumption could be wrong (but note that I am guessing, so it could be right too).

Assumptions about performance are quite often wrong. You could try your idea of creating new Documents all the time instead of reusing one -- I can't imagine why you assume that would be a "performance hog". See if it makes a difference. If it doesn't, fire up a profiler and see what's really filling up your memory.

DrClapa at 2007-7-14 21:29:58 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...