aspose file tools*
The moose likes XML and Related Technologies and the fly likes Java.lang.outofmemory error for xml parsing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Java.lang.outofmemory error for xml parsing" Watch "Java.lang.outofmemory error for xml parsing" New topic
Author

Java.lang.outofmemory error for xml parsing

Raje Kumar
Greenhorn

Joined: Sep 13, 2004
Posts: 2
I am Parsing an xml document and I am running 4 threads at one time.
I am getting java.lang.outofmemory error. What could be the reason for
this. and how to prevent this from happening.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You could either increase the heap size using the -Xmx JVM argument or look into splitting the XML parsing into smaller pieces using SAX, for example.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12783
    
    5
1. How large is the XML document? Building a DOM takes many times the size of the original input document since so many objects are involved and the Strings are all Unicode.
2. What are these 4 Threads doing? The parser instance may not be sharable by multiple Threads. For example, see the javax.xml.parsers.DocumentBuilder JavaDocs.
Bill
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
similar questions came up in another forum and if I have some time, I'll give stax (or simply sax) api a try. There are 2 interesting entries in Rickard Obergs weblog about the issue:
http://jroller.com/page/rickard/20040716
http://jroller.com/page/rickard/20040816
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java.lang.outofmemory error for xml parsing