[ https://issues.apache.org/jira/browse/PDFBOX-2825?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14579657#comment-14579657 ]
Tilman Hausherr commented on PDFBOX-2825: ----------------------------------------- Likely worse, like here: {code} public static byte[] toByteArray(InputStream in) throws IOException { ByteArrayOutputStream baout = new ByteArrayOutputStream(); copy(in, baout); return baout.toByteArray(); } {code} This method stores its input (that is already in memory) in a ByteArrayOutputStream in full, then copies it into an array. > Requested array size exceeds VM limit > ------------------------------------- > > Key: PDFBOX-2825 > URL: https://issues.apache.org/jira/browse/PDFBOX-2825 > Project: PDFBox > Issue Type: Bug > Components: Rendering > Affects Versions: 2.0.0 > Reporter: Dmitry Andreev > Labels: newbie > > Hi, I've got this OOM exception when trying to render big file. > {code} > Exception in thread "main" java.lang.OutOfMemoryError: Requested array size > exceeds VM limit > at java.util.Arrays.copyOf(Arrays.java:3230) > at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:113) > at > java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93) > at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:140) > at org.apache.pdfbox.io.IOUtils.copy(IOUtils.java:68) > at org.apache.pdfbox.io.IOUtils.toByteArray(IOUtils.java:50) > at > org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.from8bit(SampledImageReader.java:244) > at > org.apache.pdfbox.pdmodel.graphics.image.SampledImageReader.getRGBImage(SampledImageReader.java:149) > at > org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.getImage(PDImageXObject.java:246) > at org.apache.pdfbox.rendering.PageDrawer.drawImage(PageDrawer.java:766) > at > org.apache.pdfbox.contentstream.operator.graphics.DrawObject.process(DrawObject.java:51) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:802) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:464) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:438) > at > org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:149) > at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:180) > at > org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:205) > at > org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:136) > at > org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:69) > at > org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:56) > {code} > It's there something way to fix this? -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org