Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-03-29
2
Medium Priority
?
1,503 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 150 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

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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:
Suggested Courses

688 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