This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

OutOfMemoryError - no stack trace available  RSS feed

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am executing a program that parses some XML files and stores the extracted data into a database. There are many files with size ranging from 1.72 KB to 6.5 MB. When I am parsing the files using DOMParser, the program executes successfully. It parses some files and then terminates its execution by giving the following output:

java.lang.OutOfMemoryError
<<no stack trace available>>


When I re-execute the program and start from the file which was last processed in the previous execution, the program runs successfully. Can anyone help me out in finding what the problem is? Also, will SAX processing speed up the program execution and avoid such errors from getting thrown?
 
author and deputy
Bartender
Posts: 3150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ketan Chachad:
Also, will SAX processing speed up the program execution and avoid such errors from getting thrown?


I would say its better if you use SAX as your xml file may vary from 1kb to 6.5MB and also you are only retrieving the data and not changing any data in the XML file., this should increase the processing speed with less memory consumption.
 
Ketan KC Chachad
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Balaji for the suggestion and SAX is working perfectly fine. But is the OutOfMemoryError because the system I am currently working on has low memory? I mean will increasing the memory capacity allow me to use DOMParser?
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A DOM parser builds a huge structure in memory with objects for everything in your XML file. Since all the text becomes String objects using 16 bits per character and there is all the overhead required for other parts of the structure, you are talking a huge memory requirement.
So, the answer is yes, increasing the Java memory allocation will let you handle larger documents with DOM.
Bill
 
today's feeble attempt to support the empire
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!