Added Finding and we will work on the patch.  Thank you for prompt response!

Gary Potagal

-----Original Message-----
From: Maruan Sahyoun [mailto:[email protected]]
Sent: Monday, March 19, 2018 12:11 PM
To: [email protected]
Subject: Re: OutOfMemory error using PDFBox 2.0.4 to merge documents

Hi,

thanks for the observation. I've opened PDFBOX-4158 
(https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fissues.apa&data=02%7C01%7CGary.Potagal%40navihealth.com%7Ce15e57da99ee46878c2908d58db3fa8f%7C6e94af0345c143158632e1c94ce46b97%7C1%7C0%7C636570726508357775&sdata=82MNDvlc0v4VW3p9R1y7EDu0bOvlXO7IOigaLVAq7oQ%3D&reserved=0
che.org/jira/browse/PDFBOX-4158) for that. Please add your findings including 
screenshots and a possible patch to this issue.

BR
Maruan


> Hello,
>
> We tried using PDFBox 2.0.4 to merge PDF Documents, in order to allow the 
> user Print all documents at once from the Browser.  The resulting document is 
> sent to the print window.  In order to improve customer experience, documents 
> are merged to the Servlet HTTP Output Stream.  It’s possible for the user to 
> close the window or network to time out, resulting in Exception below.
>
> We used JProfiler to diagnose the memory leak and followed
> instructions:
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.e
> j-technologies.com%2Fresources%2Fjprofiler%2Fhelp%2Fdoc%2F%23jprofiler
> .heapWalker.memoryLeaks&data=02%7C01%7CGary.Potagal%40navihealth.com%7
> Ce15e57da99ee46878c2908d58db3fa8f%7C6e94af0345c143158632e1c94ce46b97%7
> C1%7C0%7C636570726508357775&sdata=oF0ddGNj78ZtTYf9JUmxZggqWp2mFvdA4qCg
> GjMz0Hk%3D&reserved=0
>
> BiggestObject and Allocation Screen Captures are attached.   We also observed 
> that Scratch File is not cleaned up.
>
> In reviewing the code:
>
> 1.
> org.apache.pdfbox.multipdf.PDFMergerUtility#mergeDocuments(MemoryUsage
> Setting memUsageSetting)
>
> finally{ } block loops over (PDDocument doc : tobeclosed) without catching 
> Exception, probably causing the leak that we’re seeing.
>
> 2.  org.apache.pdfbox.cos.COSDocument#close()
>
>
> if closing COSStream or COSObject results in IOException, close on 
> scratchFile is never reached.
>
> I’ll try to add debugging and use try / catch / finally on every operation to 
> see if the memory leak can be avoided.  A couple of questions?
>
> Is anyone else running into this and are there recommendations?
> Any ETA on: 
> https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fissues.apache.org%2Fjira%2Fbrowse%2FPDFBOX-3999&data=02%7C01%7CGary.Potagal%40navihealth.com%7Ce15e57da99ee46878c2908d58db3fa8f%7C6e94af0345c143158632e1c94ce46b97%7C1%7C0%7C636570726508357775&sdata=3Qqjhg9uIuDbNVeoVeE%2FLG7v2hxFAG8%2FOuo0oBWKZU0%3D&reserved=0?
>   It’s a little hard to follow, but it may make this fix a little easier.
> If the fix works, can I open a pull request for someone to review?
>
> Thank you in advance,
>
>
>         Gary Potagal
> Principal Software Engineer O: 1800.446.9614
>
>
>
>
> ===============
>
> org.apache.catalina.connector.ClientAbortException: java.io.IOException: 
> Broken pipe
>         at 
> org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:396)
>         at 
> org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:426)
>         at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:283)
>         at 
> org.apache.catalina.connector.OutputBuffer.writeByte(OutputBuffer.java:440)
>         at 
> org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:81)
>         at 
> org.apache.catalina.filters.ExpiresFilter$XServletOutputStream.write(ExpiresFilter.java:1016)
>         at 
> org.apache.pdfbox.pdfwriter.COSStandardOutputStream.write(COSStandardOutputStream.java:144)
>         at org.apache.pdfbox.cos.COSName.writePDF(COSName.java:702)
>         at 
> org.apache.pdfbox.pdfwriter.COSWriter.visitFromName(COSWriter.java:1155)
>         at org.apache.pdfbox.cos.COSName.accept(COSName.java:672)
>         at 
> org.apache.pdfbox.pdfwriter.COSWriter.visitFromDictionary(COSWriter.java:995)
>         at org.apache.pdfbox.cos.COSDictionary.accept(COSDictionary.java:1325)
>         at 
> org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:522)
>         at 
> org.apache.pdfbox.pdfwriter.COSWriter.doWriteObjects(COSWriter.java:460)
>         at 
> org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:444)
>         at 
> org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1096)
>         at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:419)
>         at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1367)
>         at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1254)
>         at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1232)
>         at
> org.apache.pdfbox.multipdf.PDFMergerUtility.mergeDocuments(PDFMergerUt
> ility.java:280)
>
>
> This email, including attachments, may contain information that is 
> privileged, confidential or is exempt from disclosure under applicable law 
> (including, but not limited to, protected health information). It is not 
> intended for transmission to, or receipt by, any unauthorized persons. If the 
> reader of this message is not the intended recipient, or the employee or 
> agent responsible for delivering the message to the intended recipient, you 
> are hereby notified that any dissemination, distribution or copying of this 
> communication is strictly prohibited. If you believe this email was sent to 
> you in error, do not read it. Please notify the sender immediately informing 
> them of the error and delete all copies and attachments of the message from 
> your system. Thank you.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected] For
> additional commands, e-mail: [email protected]
--
Maruan Sahyoun

FileAffairs GmbH
Josef-Schappe-Straße 21
40882 Ratingen

Tel: +49 (2102) 89497 88
Fax: +49 (2102) 89497 91
[email protected]
https://na01.safelinks.protection.outlook.com/?url=www.fileaffairs.de&data=02%7C01%7CGary.Potagal%40navihealth.com%7Ce15e57da99ee46878c2908d58db3fa8f%7C6e94af0345c143158632e1c94ce46b97%7C1%7C0%7C636570726508357775&sdata=%2BMSBQyioZPgqfNBo2%2BhaRihVS4Z3y9cu%2BXUFbtrPuoA%3D&reserved=0

Geschäftsführer: Maruan Sahyoun
Handelsregister: AG Düsseldorf, HRB 53837
UST.-ID: DE248275827

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected] For additional 
commands, e-mail: [email protected]

This email, including attachments, may contain information that is privileged, 
confidential or is exempt from disclosure under applicable law (including, but 
not limited to, protected health information). It is not intended for 
transmission to, or receipt by, any unauthorized persons. If the reader of this 
message is not the intended recipient, or the employee or agent responsible for 
delivering the message to the intended recipient, you are hereby notified that 
any dissemination, distribution or copying of this communication is strictly 
prohibited. If you believe this email was sent to you in error, do not read it. 
Please notify the sender immediately informing them of the error and delete all 
copies and attachments of the message from your system. Thank you.

Reply via email to