• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java.lang.outofmemory error for xml parsing

 
Raje Kumar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic