xmlgraphics-fop-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Douglas" <edoug...@blockhouse.com>
Subject Fop Memory Leak
Date Thu, 26 May 2011 14:03:22 GMT
I could use some help tracking this down.  I created a Print Preview
program but it just runs out of memory after a dozen or two pages.
I started with a program which generates XML data, transforms it into FO
data, then transforms that.
There are 2 transforms in it, one to create a PDF and one for Print
Preview.
When I tried to create a large FO and generate a PDF of 1000+ pages it
crashed, out of memory.
I changed it to break the output.  It now stores an array of FO files
for no more than 10 pages each, using XSL's intiial-page-number to store
a starting point for each document fragment.
To create a PDF I call the transformer to get the PDF from the Fop
output stream in byte format for each FO.  Then I load them into PDF
objects using the pfdbox project, create a new PDF with it and copy in
the pages to merge them.
This works great for PDF.  I was able to generate a report this way of
over 1800 pages.
Now I try it for print preview, generating 10 pages at a time, calling
the render process again when a new size or a page from a different
block is requested.
The memory use never drops on these calls but in 2 places I see it
jumping up, whenever it calls Transformer.transform with a PNGRenderer,
and whenever I try to create a new image for a page even though I'm only
generating 10 pages and on each render I replace the previous array of
images.
If I do something as simple as this the memory jumps up sometimes on the
create.
myBufferedImage = myImageArray.get(pageNum);
myBufferedImage.flush();
myBufferedImage = new
BufferedImage(sameWidthAsOldImage,sameHeightAsOldImage);
It does this if I call PNGRenderer.getPageImage(pageNum) (from
Java2DRenderer), so I tried creating the BufferedImage (or VolatileImage
same issue) myself and using the Java2DRenderer.print method to draw the
page on it.  Memory use keeps increasing on the image create and on the
transform.
The transform is all done in one method, with only the FopFactory and
TransformerFactory remaining (created static final to the class) after
the method so a second call shouldn't use any more than the first.

Mime
View raw message