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 ?