[xsl] memory leaks after java-calls

Subject: [xsl] memory leaks after java-calls
From: "Lensch, Thomas" <Lensch@xxxxxxxx>
Date: Thu, 15 Feb 2007 13:00:49 +0100

i'm using xalan (2.6.0), xerces (2.6.2).

My xsl script calls java:

java:de.juris.util.SimpleHTMLDiff.getSimpleHTMLDiffAsDOM($in1, $in2)

$in1 and $in2 contain some data (String).

The java code looks as follows:

public static DocumentFragment getSimpleHTMLDiffAsDOM(String left,
String right) {
 // do something with these Strings, result kept in String fragment
 // and then:
			// Create a DOM builder and parse the fragment
			DocumentBuilder dBuilder =
			Document d = dBuilder.parse(new InputSource(new

			DocumentFragment docfrag =
			Node node = d.getDocumentElement();

			// Move the nodes into the fragment
			while (node.hasChildNodes())


			// Return the fragment

			return docfrag;

Because xalan runs in an web (tomcat) environment many of these calls
come in and used memory grows.

It seems that all these docfrags are kept in memory, isn't it?
Does the garbage collector find all these docfrags which aren't needed
any more?
Is it possible to change this behaviour so that the docfrags are deleted
in memory?

Best regards,

Current Thread