Solved

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

Posted on 2009-03-29
2
1,484 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

623 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