Dear All,

I use FOP (1.0) for processing a simple two page FO file with one complex
SVG file on each page.

In my web app (bean) I instantiate the following Producer class once and
then I call its createPDF method several times. I get very quicky Heap Space
errors. In the NetBeans profiler I've noticed that each iteration leaves
couple of objects in the memory which are not relased even when the garbage
collector is triggered. 

All these objects are Batik related. Like Batik would be used for SVG
rendering, but not released at all at the end. I can send the profiler
snapshot if you like.

Or is there any mistake in my code which is causing this?

Jan


public class Producer {

    FopFactory fopFactory = FopFactory.newInstance();
    Transformer transformer =
TransformerFactory.newInstance().newTransformer();

    public Producer() throws Exception {
        fopFactory.setUserConfig(getFopConfig());
    }

    private Configuration getFopConfig() throws Exception {
        DefaultConfigurationBuilder cfgBuilder = new
DefaultConfigurationBuilder();
        return
cfgBuilder.build(this.getClass().getResourceAsStream(Settings.resourceBasePa
th + "config/fop.xml"));
    }

    public void createPDF(File foFile, File output) throws Exception {

        OutputStream out = new BufferedOutputStream(new
FileOutputStream(output));
        
        Fop fop = null;
        Result pdfResult = null;
        SAXSource source = null;
        
        try {
        
            fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);

            InputStream inputStream = new FileInputStream(foFile);
            Reader reader = new InputStreamReader(inputStream, "UTF-8");
            InputSource is = new InputSource(reader);
            source = new SAXSource(is);
            source.setXMLReader(XMLReaderFactory.createXMLReader());
            pdfResult = new SAXResult(fop.getDefaultHandler());
            transformer.transform(source, pdfResult);            

        } finally {
            out.close();
            fop = null;            
        }
    }

}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to