[jdom-interest] Speed/memory Improvement from b8 to b9 but no1.1.x support

Alex Rosen arosen at novell.com
Fri May 9 07:39:12 PDT 2003


Sun has been tweaking the memory management in StringBuffer for a long
time now, and there are several different bug reports related to this.
The problem that JDOM encounters is not confined to 1.4.1 - I'm pretty
sure it happens in some versions of 1.2 and 1.3 also.

If you want to stick with beta 8 because of JDK 1.1 support, the simple
workaround is to replace

        textBuffer.setLength(0);

with

        textBuffer = new StringBuffer();

in SAXHandler.flushCharacters(). This prevents the memory-sharing
behavior between the String and the StringBuffer, which caused this
particular problem. (JDOM beta 9 uses a slightly more efficient
mechanism which you could copy, but this one line should help quite a
bit.)

IIRC JDOM is becoming more integrated with XPath via Jaxen, which is
1.2 only, which is why we're ditching 1.1.

Alex Rosen
Novell, Inc.




More information about the jdom-interest mailing list