Solved

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

Posted on 2009-03-29
2
1,461 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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html Table Looping (part 2) 5 35
java mysql insert application 14 44
Running JavaFX on the Raspberry Pi 27 135
I'm using XML(xslt) - How to fix the BOM issue 5 23
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…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

749 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