Hi Maruan, i think it is not a problem with the multiple threads. It runs fine most of the time. Despite the times it doesn't. :) We run a lot of documents trough this. I try to get my hands on a document which crashes.
We call PDFBox from clojure, so here a short example code i used to experiment with several pdfs. (let [writer (PDFImageWriter.)] (.writeImage writer (PDDocument/loadNonSeq (java.io.File. filename) (RandomAccessFile. (java.io.File. "temp") "rw")) "png" "" 1 1 "example" BufferedImage/TYPE_INT_RGB 300)) Production code looks different but does the same. Best regards Florian 2013/5/13 Maruan Sahyoun <sahy...@fileaffairs.de> > Hi Florian, > > could also be because you are running multiple threads. Maybe worth trying > to limit the threads running to 1 through the Executors ThreadPool. > > Maybe you can share some of the code with us. > > BR > Maruan Sahyoun > > Am 13.05.2013 um 14:05 schrieb Florian Over <florian.o...@googlemail.com>: > > > Hi, > > we are running PDFBox 1.8.1 on a modern Ubuntu with Oracle JDK 1.7 > > I tried the PDFToImage command line tool on a lot of PDFs and could never > > see this behavior. > > It only occurs in production. :) > > > > I will try to get my hands on a PDF which produces this behavior. > > > > Best regards Florian > > > > > > 2013/5/13 Maruan Sahyoun <sahy...@fileaffairs.de> > > > >> Hi Florian, > >> > >> I'm not aware of any bug in that area. Could you try the PDFToImage > >> command line tool? Which version of PDFBox are you using? > >> > >> BR > >> Maruan Sahyoun > >> > >> Am 13.05.2013 um 11:52 schrieb Florian Over < > florian.o...@googlemail.com>: > >> > >>> Hi, > >>> before entering a bug report i would like to know if there is a known > bug > >>> regarding > >>> drawImage in PageDrawer? > >>> > >>> I did not found any related bugs in Jira, so i'm asking here. > >>> > >>> What we see is the following behavior: > >>> We create thumbnails of the first page of a PDF. > >>> But for some PDFs we see that threads allocate a lot of memory (> > 500mb) > >> in > >>> one int[]. > >>> > >>> I have added two stacktraces with the same behavior. > >>> > >>> Any ideas on this? > >>> > >>> Best regards Florian > >>> > >>> Stacktrace 1: > >>> pool-10-thread-13 > >>> at java.lang.OutOfMemoryError.<init>()V (OutOfMemoryError.java:48) > >>> at java.awt.image.DataBufferInt.<init>(I)V (DataBufferInt.java:75) > >>> at > >>> > >> > java.awt.image.Raster.createPackedRaster(III[ILjava/awt/Point;)Ljava/awt/image/WritableRaster; > >>> (Raster.java:470) > >>> at > >>> > >> > java.awt.image.DirectColorModel.createCompatibleWritableRaster(II)Ljava/awt/image/WritableRaster; > >>> (DirectColorModel.java:1032) > >>> at java.awt.image.BufferedImage.<init>(III)V (BufferedImage.java:338) > >>> at > >>> > >> > sun.java2d.loops.GraphicsPrimitive.convertFrom(Lsun/java2d/loops/Blit;Lsun/java2d/SurfaceData;IIIILsun/java2d/SurfaceData;I)Lsun/java2d/SurfaceData; > >>> (GraphicsPrimitive.java:557) > >>> at > >>> > >> > sun.java2d.loops.GraphicsPrimitive.convertFrom(Lsun/java2d/loops/Blit;Lsun/java2d/SurfaceData;IIIILsun/java2d/SurfaceData;)Lsun/java2d/SurfaceData; > >>> (GraphicsPrimitive.java:541) > >>> at > >>> > >> > sun.java2d.loops.MaskBlit$General.MaskBlit(Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;Lsun/java2d/pipe/Region;IIIIII[BII)V > >>> (MaskBlit.java:189) > >>> at > >>> > >> > sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;Lsun/java2d/pipe/Region;IIIIII)V > >>> (Blit.java:204) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.blitSurfaceData(Lsun/java2d/SunGraphics2D;Lsun/java2d/pipe/Region;Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Lsun/java2d/loops/SurfaceType;Lsun/java2d/loops/SurfaceType;IIIIIILjava/awt/Color;)V > >>> (DrawImage.java:956) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.renderImageCopy(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;Ljava/awt/Color;IIIIII)Z > >>> (DrawImage.java:578) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.copyImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;IILjava/awt/Color;)Z > >>> (DrawImage.java:71) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.copyImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;IILjava/awt/Color;Ljava/awt/image/ImageObserver;)Z > >>> (DrawImage.java:1011) > >>> at > >>> > >> > sun.java2d.pipe.ValidatePipe.copyImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;IILjava/awt/Color;Ljava/awt/image/ImageObserver;)Z > >>> (ValidatePipe.java:186) > >>> at > >>> > >> > sun.java2d.SunGraphics2D.drawImage(Ljava/awt/Image;IILjava/awt/Color;Ljava/awt/image/ImageObserver;)Z > >>> (SunGraphics2D.java:3084) > >>> at > >>> > >> > sun.java2d.SunGraphics2D.drawImage(Ljava/awt/Image;IILjava/awt/image/ImageObserver;)Z > >>> (SunGraphics2D.java:3069) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.makeBufferedImage(Ljava/awt/Image;Ljava/awt/Color;IIIII)Ljava/awt/image/BufferedImage; > >>> (DrawImage.java:334) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.renderImageXform(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;Ljava/awt/geom/AffineTransform;IIIIILjava/awt/Color;)V > >>> (DrawImage.java:394) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.transformImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;IILjava/awt/geom/AffineTransform;I)V > >>> (DrawImage.java:216) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.transformImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;Ljava/awt/geom/AffineTransform;Ljava/awt/image/ImageObserver;)Z > >>> (DrawImage.java:1082) > >>> at > >>> > >> > sun.java2d.pipe.ValidatePipe.transformImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;Ljava/awt/geom/AffineTransform;Ljava/awt/image/ImageObserver;)Z > >>> (ValidatePipe.java:230) > >>> at > >>> > >> > sun.java2d.SunGraphics2D.drawImage(Ljava/awt/Image;Ljava/awt/geom/AffineTransform;Ljava/awt/image/ImageObserver;)Z > >>> (SunGraphics2D.java:3210) > >>> at > >>> > >> > org.apache.pdfbox.pdfviewer.PageDrawer.drawImage(Ljava/awt/Image;Ljava/awt/geom/AffineTransform;)V > >>> (PageDrawer.java:473) > >>> at > >>> > >> > org.apache.pdfbox.util.operator.pagedrawer.Invoke.process(Lorg/apache/pdfbox/util/PDFOperator;Ljava/util/List;)V > >>> (Invoke.java:109) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFStreamEngine.processOperator(Lorg/apache/pdfbox/util/PDFOperator;Ljava/util/List;)V > >>> (PDFStreamEngine.java:554) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFStreamEngine.processSubStream(Lorg/apache/pdfbox/cos/COSStream;)V > >>> (PDFStreamEngine.java:268) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFStreamEngine.processSubStream(Lorg/apache/pdfbox/pdmodel/PDPage;Lorg/apache/pdfbox/pdmodel/PDResources;Lorg/apache/pdfbox/cos/COSStream;)V > >>> (PDFStreamEngine.java:235) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFStreamEngine.processStream(Lorg/apache/pdfbox/pdmodel/PDPage;Lorg/apache/pdfbox/pdmodel/PDResources;Lorg/apache/pdfbox/cos/COSStream;)V > >>> (PDFStreamEngine.java:215) > >>> at > >>> > >> > org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(Ljava/awt/Graphics;Lorg/apache/pdfbox/pdmodel/PDPage;Ljava/awt/Dimension;)V > >>> (PageDrawer.java:125) > >>> at > >>> > >> > org.apache.pdfbox.pdmodel.PDPage.convertToImage(II)Ljava/awt/image/BufferedImage; > >>> (PDPage.java:769) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFImageWriter.writeImage(Lorg/apache/pdfbox/pdmodel/PDDocument;Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;II)Z > >>> (PDFImageWriter.java:115) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFImageWriter.writeImage(Lorg/apache/pdfbox/pdmodel/PDDocument;Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;)Z > >>> (PDFImageWriter.java:89) > >>> ... > >>> at > >> java.util.concurrent.Executors$RunnableAdapter.call()Ljava/lang/Object; > >>> (Executors.java:471) > >>> at java.util.concurrent.FutureTask$Sync.innerRun()V > >> (FutureTask.java:334) > >>> at java.util.concurrent.FutureTask.run()V (FutureTask.java:166) > >>> at > >>> > >> > java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V > >>> (ThreadPoolExecutor.java:1145) > >>> at java.util.concurrent.ThreadPoolExecutor$Worker.run()V > >>> (ThreadPoolExecutor.java:615) > >>> at java.lang.Thread.run()V (Thread.java:722) > >>> > >>> > >>> Stacktrace 2: > >>> pool-10-thread-15 > >>> at > >>> > >> > sun.java2d.loops.MaskBlit$General.MaskBlit(Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;Lsun/java2d/pipe/Region;IIIIII[BII)V > >>> (MaskBlit.java:180) > >>> at > >>> > >> > sun.java2d.loops.Blit$GeneralMaskBlit.Blit(Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Ljava/awt/Composite;Lsun/java2d/pipe/Region;IIIIII)V > >>> (Blit.java:204) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.blitSurfaceData(Lsun/java2d/SunGraphics2D;Lsun/java2d/pipe/Region;Lsun/java2d/SurfaceData;Lsun/java2d/SurfaceData;Lsun/java2d/loops/SurfaceType;Lsun/java2d/loops/SurfaceType;IIIIIILjava/awt/Color;)V > >>> (DrawImage.java:956) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.renderImageCopy(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;Ljava/awt/Color;IIIIII)Z > >>> (DrawImage.java:578) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.copyImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;IILjava/awt/Color;)Z > >>> (DrawImage.java:71) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.copyImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;IILjava/awt/Color;Ljava/awt/image/ImageObserver;)Z > >>> (DrawImage.java:1011) > >>> at > >>> > >> > sun.java2d.pipe.ValidatePipe.copyImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;IILjava/awt/Color;Ljava/awt/image/ImageObserver;)Z > >>> (ValidatePipe.java:186) > >>> at > >>> > >> > sun.java2d.SunGraphics2D.drawImage(Ljava/awt/Image;IILjava/awt/Color;Ljava/awt/image/ImageObserver;)Z > >>> (SunGraphics2D.java:3084) > >>> at > >>> > >> > sun.java2d.SunGraphics2D.drawImage(Ljava/awt/Image;IILjava/awt/image/ImageObserver;)Z > >>> (SunGraphics2D.java:3069) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.makeBufferedImage(Ljava/awt/Image;Ljava/awt/Color;IIIII)Ljava/awt/image/BufferedImage; > >>> (DrawImage.java:334) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.renderImageXform(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;Ljava/awt/geom/AffineTransform;IIIIILjava/awt/Color;)V > >>> (DrawImage.java:394) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.transformImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;IILjava/awt/geom/AffineTransform;I)V > >>> (DrawImage.java:216) > >>> at > >>> > >> > sun.java2d.pipe.DrawImage.transformImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;Ljava/awt/geom/AffineTransform;Ljava/awt/image/ImageObserver;)Z > >>> (DrawImage.java:1082) > >>> at > >>> > >> > sun.java2d.pipe.ValidatePipe.transformImage(Lsun/java2d/SunGraphics2D;Ljava/awt/Image;Ljava/awt/geom/AffineTransform;Ljava/awt/image/ImageObserver;)Z > >>> (ValidatePipe.java:230) > >>> at > >>> > >> > sun.java2d.SunGraphics2D.drawImage(Ljava/awt/Image;Ljava/awt/geom/AffineTransform;Ljava/awt/image/ImageObserver;)Z > >>> (SunGraphics2D.java:3210) > >>> at > >>> > >> > org.apache.pdfbox.pdfviewer.PageDrawer.drawImage(Ljava/awt/Image;Ljava/awt/geom/AffineTransform;)V > >>> (PageDrawer.java:473) > >>> at > >>> > >> > org.apache.pdfbox.util.operator.pagedrawer.Invoke.process(Lorg/apache/pdfbox/util/PDFOperator;Ljava/util/List;)V > >>> (Invoke.java:109) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFStreamEngine.processOperator(Lorg/apache/pdfbox/util/PDFOperator;Ljava/util/List;)V > >>> (PDFStreamEngine.java:554) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFStreamEngine.processSubStream(Lorg/apache/pdfbox/cos/COSStream;)V > >>> (PDFStreamEngine.java:268) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFStreamEngine.processSubStream(Lorg/apache/pdfbox/pdmodel/PDPage;Lorg/apache/pdfbox/pdmodel/PDResources;Lorg/apache/pdfbox/cos/COSStream;)V > >>> (PDFStreamEngine.java:235) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFStreamEngine.processStream(Lorg/apache/pdfbox/pdmodel/PDPage;Lorg/apache/pdfbox/pdmodel/PDResources;Lorg/apache/pdfbox/cos/COSStream;)V > >>> (PDFStreamEngine.java:215) > >>> at > >>> > >> > org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(Ljava/awt/Graphics;Lorg/apache/pdfbox/pdmodel/PDPage;Ljava/awt/Dimension;)V > >>> (PageDrawer.java:125) > >>> at > >>> > >> > org.apache.pdfbox.pdmodel.PDPage.convertToImage(II)Ljava/awt/image/BufferedImage; > >>> (PDPage.java:769) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFImageWriter.writeImage(Lorg/apache/pdfbox/pdmodel/PDDocument;Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;II)Z > >>> (PDFImageWriter.java:115) > >>> at > >>> > >> > org.apache.pdfbox.util.PDFImageWriter.writeImage(Lorg/apache/pdfbox/pdmodel/PDDocument;Ljava/lang/String;Ljava/lang/String;IILjava/lang/String;)Z > >>> (PDFImageWriter.java:89) > >>> ... > >>> at clojure.lang.AFn.run()V (AFn.java:24) > >>> at > >>> java.util.concurrent.Executors$RunnableAdapter.call()Ljava/lang/Object; > >>> (Executors.java:471) > >>> at java.util.concurrent.FutureTask$Sync.innerRun()V > >> (FutureTask.java:334) > >>> at java.util.concurrent.FutureTask.run()V (FutureTask.java:166) > >>> at > >>> > >> > java.util.concurrent.ThreadPoolExecutor.runWorker(Ljava/util/concurrent/ThreadPoolExecutor$Worker;)V > >>> (ThreadPoolExecutor.java:1145) > >>> at java.util.concurrent.ThreadPoolExecutor$Worker.run()V > >>> (ThreadPoolExecutor.java:615) > >>> at java.lang.Thread.run()V (Thread.java:722) > >> > >