[jdom-interest] RE: Parsing an 16MB-XML-File (Andreas Lorenz)

Rajendra Paul rajendra at loudeye.com
Thu Jan 25 10:33:24 PST 2001


I am processing bigger documents and had to find ways to work around the
darn but valid "Out of Memory Error".   Document builder using either DOM or
SAX is a memory hog. Just watch perfmon as you fire up your program.

Here are my suggestions to work around it:

1) Stop as many running programs and apps as you can.

2) Use command line parameters like -Xms to increase initial and maximum
stack and/or heap size. 

Example: 
> java -Xms%HEAP_INITIAL_SIZE% -Xmx%HEAP_MAX_SIZE% -Xss%STACK_SIZE%
-classpath %MYCLASSPATH% MYApp %1 %2

3) Use StringBuffer and String Tokenizer if your document is simple. This
may be your real choice if your computer does not have a lot of memory to go
around.

4) Add memory to your computer.

5) Do not use java Strings, use StringBuffer in your program. Set Strings to
null after use so that they are definitely garbage collected.

Please let me know what worked best for you.


Rajendra Paul
Loudeye Technologies
Seattle WA

=== Original message below ====================
Date: Wed, 24 Jan 2001 11:37:14 +0100
From: Andreas Lorenz <andreas.lorenz at isb-ka.de>
To: jdom-interest at jdom.org
Subject: [jdom-interest] Parsing an 16MB-XML-File

HI !

I've got a problem parsing an Xml - File that includes 16MB base64
encoded Binaries.
I use the SAXBuilder:

SAXBuilder builder = new SAXBuilder(true);
        Document doc = builder.build(file);

While running the programm this Error message occurs:
java.lang.OutOfMemoryError
 <<no stack trace available>>

Has anybody an idea  ?

Thanks,
Andy



More information about the jdom-interest mailing list