Dushyanth Balasubramanian created PDFBOX-4876:
-------------------------------------------------

             Summary: OOM issue in using PDFBOX
                 Key: PDFBOX-4876
                 URL: https://issues.apache.org/jira/browse/PDFBOX-4876
             Project: PDFBox
          Issue Type: Bug
    Affects Versions: 2.0.19
            Reporter: Dushyanth Balasubramanian


I see a lot of OOM for many documents which are either big in size or have many 
objects per page or complex images. We started the project with JVM size of 4GB 
and now we have increased it to 24GB JVM memory. The OOM issues have reduced 
but we still see some OOM issues. We have followed all the recommendations 
given here:

[https://pdfbox.apache.org/2.0/faq.html]

 

Here is the stack trace. Any recommendations for preventing OOM? Thanks.

****************************************************************************************************************************************************************************************************
Stack 1
-------

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 
[?:1.8.0_172]
 at 
com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:125)
 [guava-27.0.1-jre.jar:?]
 at 
com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:57)
 [guava-27.0.1-jre.jar:?]
 at 
com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:78)
 [guava-27.0.1-jre.jar:?]
 at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
[?:1.8.0_172]
 at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
[?:1.8.0_172]
 at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]
Caused by: java.lang.OutOfMemoryError
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
~[?:1.8.0_172]
 at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 ~[?:1.8.0_172]
 at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 ~[?:1.8.0_172]
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
~[?:1.8.0_172]
 at 
java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598) 
~[?:1.8.0_172]
 at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1066) ~[?:1.8.0_172]
 ... 23 more
Caused by: java.lang.OutOfMemoryError: Java heap space
 at java.util.Arrays.copyOf(Arrays.java:3236) ~[?:1.8.0_172]
 at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118) 
~[?:1.8.0_172]
 at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) 
~[?:1.8.0_172]
 at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153) 
~[?:1.8.0_172]
 at 
org.apache.pdfbox.pdfwriter.COSStandardOutputStream.write(COSStandardOutputStream.java:129)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.io.IOUtils.copy(IOUtils.java:70) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1220) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:475) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:158) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:526) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.pdfwriter.COSWriter.doWriteObjects(COSWriter.java:464) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:448) 
~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1113) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:452) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1386) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1273) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1357) 
~[pdfbox-2.0.19.jar:2.0.19] 
****************************************************************************************************************************************************************************************************
Stack 2
-------

Caused by: java.lang.OutOfMemoryError
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
~[?:1.8.0_172]
 at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 ~[?:1.8.0_172]
 at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 ~[?:1.8.0_172]
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
~[?:1.8.0_172]
 at 
java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598) 
~[?:1.8.0_172]
 at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1066) ~[?:1.8.0_172]
 ... 23 more
Caused by: java.lang.OutOfMemoryError: Java heap space
 at java.awt.image.DataBufferByte.<init>(DataBufferByte.java:92) ~[?:1.8.0_172]
 at 
java.awt.image.ComponentSampleModel.createDataBuffer(ComponentSampleModel.java:445)
 ~[?:1.8.0_172]
 at sun.awt.image.ByteInterleavedRaster.<init>(ByteInterleavedRaster.java:90) 
~[?:1.8.0_172]
 at 
sun.awt.image.ByteInterleavedRaster.createCompatibleWritableRaster(ByteInterleavedRaster.java:1281)
 ~[?:1.8.0_172]
 at 
sun.awt.image.ByteInterleavedRaster.createCompatibleWritableRaster(ByteInterleavedRaster.java:1292)
 ~[?:1.8.0_172]
 at org.apache.pdfbox.filter.DCTFilter.fromBGRtoRGB(DCTFilter.java:312) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.filter.DCTFilter.decode(DCTFilter.java:148) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.cos.COSInputStream.create(COSInputStream.java:84) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.cos.COSStream.createInputStream(COSStream.java:246) 
~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.pdmodel.common.PDStream.createInputStream(PDStream.java:241) 
~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.createInputStream(PDImageXObject.java:776)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.from8bit(SampledImageReader.java:373)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:226)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:479)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:460)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:1130) 
~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:67)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:875)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:509)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:483)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:156)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:270) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:321) 
~[pdfbox-2.0.19.jar:2.0.19]
 at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:243) 
~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:229)
 ~[pdfbox-2.0.19.jar:2.0.19]
****************************************************************************************************************************************************************************************************
Stack 3
-------
Caused by: java.lang.OutOfMemoryError
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
~[?:1.8.0_172]
 at 
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 ~[?:1.8.0_172]
 at 
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 ~[?:1.8.0_172]
 at java.lang.reflect.Constructor.newInstance(Constructor.java:423) 
~[?:1.8.0_172]
 at 
java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:598) 
~[?:1.8.0_172]
 at java.util.concurrent.ForkJoinTask.get(ForkJoinTask.java:1066) ~[?:1.8.0_172]
 ... 23 more
Caused by: java.lang.OutOfMemoryError: Java heap space
 at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:75) ~[?:1.8.0_172]
 at java.awt.image.Raster.createPackedRaster(Raster.java:467) ~[?:1.8.0_172]
 at 
java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032)
 ~[?:1.8.0_172]
 at java.awt.image.BufferedImage.<init>(BufferedImage.java:333) ~[?:1.8.0_172]
 at 
org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.applyMask(PDImageXObject.java:587)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:486)
 ~[pdfbox-2.0.19.jar:2.0.19]
 at 
org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:460)
 ~[pdfbox-2.0.19.jar:2.0.19]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to