[ 
https://issues.apache.org/jira/browse/PDFBOX-2688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14326490#comment-14326490
 ] 

Tilman Hausherr commented on PDFBOX-2688:
-----------------------------------------

I ran a slightly different version of your code, I didn't use the remote URL, 
as this would put a load on that server.
I stopped after 7000 requests because the pc was beginning to interfere with 
other stuff. The heap was slightly above 1.5GB (jconsole) and the process 
itself was at 2.2GB. I'm using Tomcat 8.0.3 with default settings on W7.

> sun.java2d.Disposer leak when using pdf to image conversion in a 
> server(tomcat)
> -------------------------------------------------------------------------------
>
>                 Key: PDFBOX-2688
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2688
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 1.8.8
>            Reporter: Ankit Khanal
>
> I am running with 6GB of heap space and running PDF to PNG conversion in a 
> servlet container(tomcat). This happens only when running thousands of 
> requests for conversion.
> JVM memory statistics shows heap space never going above 1GB and non-heap 
> memory is also constant but the linux process or windows process seems to 
> consume around 8GB of memory.
> Heap dump shows that the largest object is sun.java2d.Disposer and is around 
> 200MB.
> It seems that the leaked memory is native memory used by java2d and not 
> accounted in the heap memory statistic but this growth of sun.java2d.Disposer 
> memory is proportional to the growth of process memory(linux 'top' command).
> {code}
>               BufferedImage image = null;
>               ByteArrayInputStream pdfStream = getpdfbytesfromExistingDoc();
>               PDDocument document = null;
>               PDPage page = null;
>               COSDocument cosDoc = null;
>               PDFParser parser = null;
>               try {
>                       parser = new PDFParser(pdfStream);
>                       parser.parse();
>                       cosDoc = parser.getDocument();
>                       document = new PDDocument(cosDoc);
>                       @SuppressWarnings("unchecked")
>                       List<PDPage> pages = 
> document.getDocumentCatalog().getAllPages();
>                       page = pages.get(0);
>                       int imageType = BufferedImage.TYPE_INT_ARGB;
>                       image = page.convertToImage(imageType, 72);
>               } finally {
>                       if (cosDoc != null) {
>                               cosDoc.close();
>                       }
>                       if (parser != null) {
>                               parser.clearResources();
>                       }
>                       if (document != null) {
>                               if (page != null) {
>                                       page.clear();
>                               }
>                               document.close();
>                       }
>               }
>               return image;
>       }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to