pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Magnus Landrø <stefan.lan...@gmail.com>
Subject Re: java.lang.OutOfMemoryError: Java heap space when converting PDF with Version 2.0.0
Date Tue, 13 May 2014 06:18:21 GMT
If you still believe it's a memory leak in pdfbox, I recommend creating a
heap dump by starting the application using

java -XX:+HeapDumpOnOutOfMemoryError ...

http://www.eclipse.org/mat/ is great for analyzing heap dumps

Stefan


2014-05-12 18:40 GMT+02:00 Tilman Hausherr <THausherr@t-online.de>:

> Can you try a higher -Xmx value?
>
> Tilman
>
> Am 12.05.2014 17:41, schrieb Francesca.Herpertz@sungard.com:
>
>>
>> Hi,
>>
>> I was running some unit tests to see if the fix for the following bug
>> https://issues.apache.org/jira/browse/PDFBOX-1426 was working for our
>> project.
>>
>> I wanted to test as well that I was not introducing  some problems
>> through using an unreleased version.
>>
>> The following error occurred while converting PDF to TIF
>>
>> Caused by: java.lang.OutOfMemoryError: Java heap space
>>
>>       at java.awt.image.DataBufferInt.<init>(_DataBufferInt.java:41_)
>>
>>       at java.awt.image.Raster.createPackedRaster(_Raster.java:458_)
>>
>>       at java.awt.image.DirectColorModel.createCompatibleWritableRaster
>> (_DirectColorModel.java:1015_)
>>
>>       at java.awt.image.BufferedImage.<init>(_BufferedImage.java:321_)
>>
>>       at org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.
>> getStencilImage(_SampledImageReader.java:68_)
>>
>>       at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.
>> getStencilImage(_PDImageXObject.java:198_)
>>
>>       at org.apache.pdfbox.util.operator.pagedrawer.Invoke.
>> process(_Invoke.java:74_)
>>
>>       at org.apache.pdfbox.util.PDFStreamEngine.processOperator(_
>> PDFStreamEngine.java:529_)
>>
>>       at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(_
>> PDFStreamEngine.java:254_)
>>
>>       at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(_
>> PDFStreamEngine.java:221_)
>>
>>       at org.apache.pdfbox.util.PDFStreamEngine.processStream(
>> _PDFStreamEngine.java:203_)
>>
>>       at org.apache.pdfbox.rendering.PageDrawer.drawPage(_
>> PageDrawer.java:162_)
>>
>>       at org.apache.pdfbox.rendering.PDFRenderer.renderPage(_
>> PDFRenderer.java:214_)
>>
>>       at org.apache.pdfbox.rendering.PDFRenderer.renderImage(_
>> PDFRenderer.java:147_)
>>
>>       at org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(_
>> PDFRenderer.java:82_)
>>
>>       at com.sungard.liberty.applications.PDFSplitterServiceImpl.
>> convertPDFtoTIFF(_PDFSplitterServiceImpl.java:76_)
>>
>>       at com.sungard.liberty.applications.PDFSplitterServiceTest.
>> parseSinglePDF(_PDFSplitterServiceTest.java:46_)
>>
>>       at sun.reflect.NativeMethodAccessorImpl.invoke0(_Native Method_)
>>
>>       at sun.reflect.NativeMethodAccessorImpl.invoke(_
>> NativeMethodAccessorImpl.java:39_)
>>
>>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(_
>> DelegatingMethodAccessorImpl.java:25_)
>>
>>       at java.lang.reflect.Method.invoke(_Method.java:597_)
>>
>>       at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(_
>> FrameworkMethod.java:45_)
>>
>>       at org.junit.internal.runners.model.ReflectiveCallable.run(_
>> ReflectiveCallable.java:15_)
>>
>>       at org.junit.runners.model.FrameworkMethod.invokeExplosively(_
>> FrameworkMethod.java:42_)
>>
>>       at org.junit.internal.runners.statements.InvokeMethod.
>> evaluate(_InvokeMethod.java:20_)
>>
>>       at org.springframework.test.context.junit4.statements.
>> RunBeforeTestMethodCallbacks.evaluate(_RunBeforeTestMethodCallbacks.
>> java:74_)
>>
>>       at org.springframework.test.context.junit4.statements.
>> RunAfterTestMethodCallbacks.evaluate(_RunAfterTestMethodCallbacks.
>> java:82_)
>>
>>       at org.springframework.test.context.junit4.statements.
>> SpringRepeat.evaluate(_SpringRepeat.java:72_)
>>
>>       at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.
>> runChild(_SpringJUnit4ClassRunner.java:240_)
>>
>>       at org.junit.runners.BlockJUnit4ClassRunner.runChild(_
>> BlockJUnit4ClassRunner.java:47_)
>>
>>       at org.junit.runners.ParentRunner$3.run(_ParentRunner.java:231_)
>>
>>       at org.junit.runners.ParentRunner$1.schedule(_
>> ParentRunner.java:60_)
>>
>> My method for conversion:
>>
>> *public**void*convertPDFtoTIFF(InputStream fis, ByteArrayOutputStream
>> fos)
>>
>> *throws*IOException {
>>
>>             Date t1 = *new*Date();
>>
>> ImageOutputStream ios = *null*;
>>
>>             PDDocument pdfDoc = *null*;
>>
>> *try*{
>>
>> /LOG/.debug("convertPDFtoTIFF input size: "+ fis.available());
>>
>> IIORegistry registry = IIORegistry./getDefaultInstance/();
>>
>> registry.registerServiceProvider(*new*TIFFImageWriterSpi());
>>
>> registry.registerServiceProvider(*new*TIFFImageReaderSpi());
>>
>> TIFFImageWriterSpi tiffspi = *new*TIFFImageWriterSpi();
>>
>> ImageWriter writer = tiffspi.createWriterInstance();
>>
>> ImageWriteParam param = writer.getDefaultWriteParam();
>>
>> param.setCompressionMode(ImageWriteParam./MODE_EXPLICIT/);
>>
>> param.setCompressionType("LZW");
>>
>> param.setCompressionQuality(0.3f);
>>
>>                   ios = ImageIO./createImageOutputStream/(fos);
>>
>> writer.setOutput(ios);
>>
>> writer.prepareWriteSequence(*null*);
>>
>> PDFParser parser = *new*PDFParser(fis);
>>
>> parser.parse();
>>
>>                   pdfDoc = parser.getPDDocument();
>>
>> *int*pageNum = pdfDoc.getNumberOfPages();
>>
>> BufferedImage images[] = *new*BufferedImage[pageNum];
>>
>> PDFRenderer renderer = *new*PDFRenderer(pdfDoc);
>>
>> *for*(*int*i = 0; i < pageNum; i++){
>>
>> images[i] = renderer.renderImageWithDPI(i, /TIFF_RESOLUTION/);
>>
>> writer.writeToSequence(*new*IIOImage(images[i], *null*, *null*), param);
>>
>>                   }
>>
>>                   Date t2 = *new*Date();
>>
>> *long*diff = Math./abs/(t1.getTime() - t2.getTime());
>>
>> /LOG/.debug("Total Pages: "+ pageNum);
>>
>> /LOG/.debug("Total Conversion Time: "+ diff / 1000 + " sec");
>>
>>             }*catch*(Throwable t){
>>
>> /LOG/.error("PDF Splitter Service failed to transform PDF to tiff");
>>
>> *throw**new*IllegalArgumentException("PDF Splitter threw an exception
>> while processing the PDF ",t);
>>
>>             } *finally*{
>>
>> *if*(pdfDoc != *null*) {
>>
>> pdfDoc.close();
>>
>>                   }
>>
>> *if*(ios != *null*) {
>>
>> ios.flush();
>>
>> ios.close();
>>
>>                   }
>>
>> *if*(fos != *null*) {
>>
>> fos.flush();
>>
>>                   }
>>
>>             }
>>
>>       }
>>
>> I cannot attach the PDF as it contains customer data but I am trying to
>> recreate this error with a different PDF.
>>
>> I hope you can help me on this matter. This would be really great.
>>
>> Thank you and kind regards,
>>
>> Francesca
>>
>> *Francesca Herpertz *| Technical Consultant iWorks| Professional Services
>> & Delivery iWorks | Insurance | SunGard |
>>
>> Solmsstraße 18, 60486 Frankfurt am Main, Germany
>> Tel + 49 (0)69 70768 510 | Mob + 49 (0) 176 1111 0143
>>
>> francesca.herpertz@sungard.com <mailto:francesca.herpertz@sungard.com>
>>
>> www.sungard.com <http://www.sungard.com/>www.sungard.com/iworksinsurance<
>> http://www.sungard.com/iworksinsurance>www.sungard.com/insurance/risk <
>> http://www.sungard.com/insurance/risk>
>>
>> P*Think before you print
>> *CONFIDENTIALITY: This e-mail (including any attachments) may contain
>> confidential, proprietary and privileged information, and unauthorized
>> disclosure or use is prohibited. If you receive this e-mail in error,
>> please notify the sender and delete this e-mail from your system.
>>
>> SunGard Systeme GmbH * Registered: Frankfurt am Main, Handelsregister
>> Frankfurt HRB 56839 * Geschäftsführer: Dean B. Gluyas, Christian U. Haas,
>> Henry Morton Miller Jr., Victoria E. Silbey
>>
>> cid:image004.jpg@01CDECBA.225FFA80
>>
>> cid:image002.jpg@01CF1C36.04A09C00
>>
>>
>


-- 
BEKK Open
http://open.bekk.no

TesTcl - a unit test framework for iRules
http://testcl.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message