pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: memory consumption PDFBox 2.0.0
Date Tue, 01 Mar 2016 17:17:01 GMT
Am 01.03.2016 um 12:35 schrieb Felix Benz-Baldas:
> Hello,
> we plan to use PDFBox 2.0.0 for converting PDFs to JPEG. We want to convert a very large
number of documents (more than one million).
> One question: Is it possible to control the memory-consumption? When I start my java
program with "-Xmx2g" I ran into a "java.lang.OutOfMemoryError: Java heap space" after about
40 minutes.
> With "-Xmx4g" the error did not occur.
> Is there a way to reduce the memory-consumption?

You could save some memory by using a scratch file:

PDDocument.load(new File("..."), MemoryUsageSetting.setupTempFileOnly());

Btw converting to JPEG only makes sense if your PDFs are photographs. 
Anything with sharp edges will look weird. Better use PNG.

Additional to Andreas answers:
- did you close every PDDocument after work?
- did you "lose" every BufferedImage after convert? Or did you rather 
keep every image of a PDF in an array?
- if you used a graphics object, did you call dispose()?


To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org

View raw message