Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

PDFBox ... Java heap space problem !!

807589Jul 14 2008 — edited Jul 14 2008
Hello,

I'm using PDFBox trying to read (2) pdf files in it, but both are big in size(About 17 MB) each.
Here is an example for what i want to do :
public void loadPdfs() { 
   String pdf1FilePath = "c:\\java long pdf1.pdf"; 
   String pdf2FilePath = "c:\\java long pdf2.pdf"; 
 
   try { 
      PDDocument pdf1File = PDDocument.load( pdf1FilePath ); 
      //....Do some stuff here. 
      pdf1File.close(); 
      Runtime.getRuntime().gc(); 
      PDDocument pdf2File = PDDocument.load( pdf2FilePath ); //This line causes the Exception. 
   } catch (IOException e) { 
      e.printStackTrace(); 
   }  
} 
I get this Exception :
org.pdfbox.exceptions.WrappedIOException: Java heap space 
. 
. 
. 
java.lang.OutOfMemoryError: Java heap space 
And if i tried to load only (1) pdf it works fine. So why does this happen ?
I do close the first pdf, and run the Garbage Collector, so when opening the second pdf, it's as if opening (1) file now, or am i mistaken ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 11 2008
Added on Jul 14 2008
2 comments
1,084 views