Eli Segev created FOP-2505:
------------------------------

             Summary: SVG -> PDF throws java.lang.OutOfMemoryError: Java heap 
space
                 Key: FOP-2505
                 URL: https://issues.apache.org/jira/browse/FOP-2505
             Project: FOP
          Issue Type: Bug
          Components: image/svg
    Affects Versions: 1.1
         Environment: Windows 7 Enterprise
            Reporter: Eli Segev
             Fix For: 1.1


This code:
                String fileName = "D:\\Users\\user\\Desktop\\12619527\\201193 
OPT 2 COLORBOARD-Cell2.svg";
            File file = new File(fileName);
            String uri = file.toURI().toString();
            ByteArrayOutputStream output = new ByteArrayOutputStream();
            org.apache.fop.svg.PDFTranscoder pdf = new 
org.apache.fop.svg.PDFTranscoder();
            TranscoderInput from = new TranscoderInput(uri);
            TranscoderOutput to = new TranscoderOutput(output);
            pdf.transcode(from, to);
            byte[] buffer = output.toByteArray();       

is run with 4GB max heap size and generates this stack trace:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at java.util.Arrays.copyOf(Arrays.java:3236)
        at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
        at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.ja
va:93)
        at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
        at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
        at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
        at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
        at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
        at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
        at java.io.BufferedWriter.write(BufferedWriter.java:230)
        at java.io.Writer.write(Writer.java:157)
        at org.apache.fop.pdf.PDFStream.add(PDFStream.java:86)
        at org.apache.fop.pdf.PDFPattern.output(PDFPattern.java:271)
        at org.apache.fop.pdf.PDFDocument.outputIndirectObject(PDFDocument.java:
1056)
        at org.apache.fop.pdf.PDFDocument.streamIndirectObject(PDFDocument.java:
1021)
        at org.apache.fop.pdf.PDFDocument.output(PDFDocument.java:997)
        at org.apache.fop.svg.PDFGraphics2D.flushPDFDocument(PDFGraphics2D.java:
480)
        at org.apache.fop.svg.PDFGraphics2D.createPattern(PDFGraphics2D.java:972
)
        at org.apache.fop.svg.PDFGraphics2D.applyPaint(PDFGraphics2D.java:836)
        at org.apache.fop.svg.PDFGraphics2D.fill(PDFGraphics2D.java:1566)
        at org.apache.batik.gvt.FillShapePainter.paint(Unknown Source)
        at org.apache.batik.gvt.CompositeShapePainter.paint(Unknown Source)
        at org.apache.batik.gvt.ShapeNode.primitivePaint(Unknown Source)
        at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
        at org.apache.batik.gvt.ShapeNode.paint(Unknown Source)
        at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Unknown Sou
rce)
        at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
        at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Unknown Sou
rce)
        at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
        at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Unknown Sou
rce)
        at org.apache.batik.gvt.AbstractGraphicsNode.paint(Unknown Source)
        at org.apache.batik.gvt.CompositeGraphicsNode.primitivePaint(Unknown Sou
rce)

What’s particular about the content is that there is a data object reused a 
great amount of times and we’re suspecting the duplication and maybe lack of 
cleanup may be causing the large memory usage
        



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

Reply via email to