Solved

xpath using dom4j- java.lang.OutOfMemoryError: Java heap space

Posted on 2009-03-29
2
1,452 Views
Last Modified: 2013-11-23
I am reading an xml file using dom4j,xpath expressions to extract fields.The xml file is very large
and I get the following error:
Exception in thread "main"  java.lang.OutOfMemoryError: Java heap space.
What is the best way to avoid this problem.
Thanks
0
Comment
Question by:aswam1975
2 Comments
 
LVL 20

Accepted Solution

by:
Venabili earned 50 total points
ID: 24017370
How do you use dom4j? Are you using DOM or SAX?
Don't use DOM -- it tries to read the whole file in the memory.  So for big files, you will always have issues -- you can increase the heap memory but as soon as you try a bigger file (or more than one) and you will be back in the same mess.

If you are using SAX and you still have this issues - post some code because you should not have issues.
0
 

Author Comment

by:aswam1975
ID: 24021091
ok- I was using dom,
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question