[ https://issues.apache.org/jira/browse/PDFBOX-4690?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17365222#comment-17365222 ]
lanshiqin edited comment on PDFBOX-4690 at 6/18/21, 3:17 AM: ------------------------------------------------------------- I found a way to prevent OOM, the maximum memory only needs 200MB,Please merge my example request。 you can set jvm -Xmx200m add to you code: {code:java} // 1. Load document with temp file only PDDocument.load(in, MemoryUsageSetting.setupTempFileOnly()) // 2. Indicates that the renderer is allowed to sub sample the image before drawing. renderer.setSubsamplingAllowed(true);{code} was (Author: lanshiqin): I found a way to prevent OOM, the maximum memory only needs 200MB,please merge my pull request you can set jvm -Xmx200m add to you code: {code:java} // 1. Load document with temp file only PDDocument.load(in, MemoryUsageSetting.setupTempFileOnly()) // 2. Indicates that the renderer is allowed to sub sample the image before drawing. renderer.setSubsamplingAllowed(true);{code} > PDFBOX running out of memory when rendering into image > ------------------------------------------------------ > > Key: PDFBOX-4690 > URL: https://issues.apache.org/jira/browse/PDFBOX-4690 > Project: PDFBox > Issue Type: Bug > Components: Rendering > Affects Versions: 2.0.11, 2.0.16, 2.0.17 > Environment: Docker Container with linux > I have allocated 10GB of RAM. > jdk8 > Reporter: Himanshu Pandey > Priority: Blocker > Attachments: crash.pdf > > > I am running into Out of memory when trying to render attached PDF at page > number 4. > {{ }} > {{ java.lang.OutOfMemoryError: Java heap spacejava.lang.OutOfMemoryError: > Java heap space at java.awt.image.DataBufferInt.<init>(DataBufferInt.java:75) > at java.awt.image.Raster.createPackedRaster(Raster.java:467) at > java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:1032) > at java.awt.image.BufferedImage.<init>(BufferedImage.java:333) at > org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:979) at > org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:62) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:848) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:503) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:477) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:150) > at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:246) at > org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:225) at > org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:164)}} -- 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