Page 1 of 1

OutOfMemory error when generating a PDF with images

PostPosted: Wed Aug 21, 2013 5:27 pm
by benpoole
Getting there! My code is combining some docxfiles (via MergeDocx) and then generating a final PDF of the combined file. The source docx file is 1,702 Kb, and contains 28 pages, with two large-ish images at the end (around 760Kb each).

When the PDF code is called, I get the stack trace. I have my JVM set up as follows:

Code: Select all
vmarg.Xmx=-Xmx1024m
vmarg.Xms=-Xms512m
vmarg.Xmca=-Xmca512k


Any ideas? Or do I just need to ramp up the heap even more?

Code: Select all
java.lang.OutOfMemoryError: Java heap space
at org.apache.batik.transcoder.wmf.tosvg.AbstractWMFPainter.getImage(Unknown Source)
at org.apache.batik.transcoder.wmf.tosvg.AbstractWMFPainter.getImage(Unknown Source)
at org.apache.batik.transcoder.wmf.tosvg.WMFPainter.paint(Unknown Source)
at org.apache.fop.image.loader.batik.ImageConverterWMF2G2D$Graphics2DImagePainterWMF.paint(ImageConverterWMF2G2D.java:98)
at org.apache.fop.render.pdf.PDFImageHandlerGraphics2D.handleImage(PDFImageHandlerGraphics2D.java:125)
at org.apache.fop.render.intermediate.AbstractIFPainter.drawImage(AbstractIFPainter.java:227)
at org.apache.fop.render.intermediate.AbstractIFPainter.drawImage(AbstractIFPainter.java:183)
at org.apache.fop.render.intermediate.AbstractIFPainter.drawImageUsingImageHandler(AbstractIFPainter.java:148)
at org.apache.fop.render.intermediate.AbstractIFPainter.drawImageUsingURI(AbstractIFPainter.java:270)
at org.apache.fop.render.pdf.PDFPainter.drawImage(PDFPainter.java:146)

Re: OutOfMemory error when generating a PDF with images

PostPosted: Thu Aug 22, 2013 4:28 am
by benpoole
To answer my own question, running the PDF generation as an entirely separate process on a pre-generated file (I was running it at the end of a length processing cycle to produce the docx file in the first place), everything works OK. So I need to profile my pre-processing code and see where it may be leaking, to then compromise the JVM when it comes to the PDF processing.

That said, FOP is not light on the heap eh ;-)