[jdom-interest] RE: Memory and Speed problems with SAXBuilder

Malachi de AElfweald malachi at tremerechantry.com
Wed Feb 26 22:07:14 PST 2003


I originally tried to email this with a zip containing the source java and 
XML files, but that
never made it to the list (due to the size).....


Malachi
------------

I have a JNLP-based application that uses SAXBuilder from the CGI-socket.
Our server was sending a 700k XML file, which we were then building on the 
client.
 
The first issue was that it kept crashing with OutOfMemoryException. We had 
to increase
the max heap size to 512M to keep it from crashing. And then, it still took 
a few minutes to
build the JDOM tree.
 
I decided to narrow down what was causing the delay and memory bloat. I 
wrote a minimal
program to just load the file from disk.
 
Using SAXBuilder took 87078ms and required -Xmx512m to not crash
Using DOMParser (without JDOM) took 2437ms
Using DOMBuilder (with deprecated File building) took 4656ms
Using DOMParser and then DOMBuilder took 4000ms
 
So, best performance was DOMParser without JDOM
 
Worst performer was SAXBuilder (which I originally used because we were 
building from
an InputStream).  Also, SAXBuilder was the ONLY one that required the huge 
amount of
heap space.
 
Building with DOMParser and then DOMBuilder was twice as slow as using 
DOMParser by itself.
 
Now, I am just providing this information as an FYI.  The company is 
requiring I rip SAXBuilder out
of all the code because the delay is unacceptable.  It is interesting to 
note that the DOMBuilder API
states that the build(file) method is deprecated because SAXBuilder is 
faster -- but it is almost 19 times
slower on this test file.
 
Malachi



More information about the jdom-interest mailing list