[jdom-interest] memory consumption - JDOM vs. DOM

Jason Hunter jhunter at collab.net
Thu Sep 7 15:08:13 PDT 2000

> Hi I am new on JDOM, I have a question regarding JDOM memory 
> consumptiom. I  wrote 2 JAVA applications on NT, one uses 
> Xerces/DOM, one uses JDOM through Xerces/SAX, they both do 
> virtually the same thing: load a large XML file into memory. 
> I got the following results. Looks like JDOM consistently uses
> more memory than Xerces/DOM does. 
> Could anyone give me some idea what was wrong?

I'm not surprised, we've been defining new functionality for JDOM but
haven't done real memory profiling.  Hopefully you'll be our first
memory profile tester!

I just checked in a change that removes the internal text caching
behavior.  This should significantly reduce the memory consumption and
also save us from the need to synchronize the cache logic manipulation
-- something that's necessary even for single-thread use because of that
strange Java "bug" as was discussed earlier on the list.

I also added an optimization to getText() for when the content is a
single String (now it just returns that string), and this should speed
up things like outputting because it avoids duplicating the string with
a string buffer.  That was just a little low-hanging fruit...

Anyway, Q, please run your tests again with the latest from CVS and post
if my change helped any.


More information about the jdom-interest mailing list