I am facing a big issue with PDFBOX: I tried to load a file of 10Mb (test.pdf) and i needed 400 Mb to load it on JVM: Here is the code sample :
final File mainFile = new File(
"C:/test.pdf");
System.out.println("File size: " + mainFile.length());
try {
PDDocument doc = PDDocument.load(mainFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Used Memory: " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
}
Is that normal ?
No, that is not normal.
I notice you hadn't closed the document (required, please read the documentation). Perhaps that accumulated in multiple runs. You also don't mention memory usage before loading the document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With