[ 
https://issues.apache.org/jira/browse/FOP-3269?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Simon Steiner updated FOP-3269:
-------------------------------
    Description: 

Generate pdf twice using -Xmx500m should not give OOM

{code:java}
public void xxx() throws Exception {
    FopConfParser fopConfParser = new FopConfParser(new File("fop.xconf"),
            new File("xxx").toURI());
    FopFactoryBuilder fopFactoryBuilder = fopConfParser.getFopFactoryBuilder();
    fopFactoryBuilder.setStrictFOValidation(false);
    FopFactory fopFactory = fopFactoryBuilder.build();
    x(fopFactory);
    fopFactory = fopFactoryBuilder.build();
    x(fopFactory);
}

private void x(FopFactory fopFactory) throws Exception {
    FOUserAgent userAgent = fopFactory.newFOUserAgent();
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    Source src = new StreamSource(new FileInputStream("out.if"));
    IFDocumentHandler documentHandler
            = userAgent.getRendererFactory().createDocumentHandler(userAgent, 
MimeConstants.MIME_PDF);
    documentHandler.setResult(new StreamResult(new NullOutputStream()));
    IFUtil.setupFonts(documentHandler);
    IFParser parser = new IFParser();
    Result res = new SAXResult(parser.getContentHandler(documentHandler, 
userAgent));
    transformer.transform(src, res);
}
{code}


> Allow GC to remove structelem tree
> ----------------------------------
>
>                 Key: FOP-3269
>                 URL: https://issues.apache.org/jira/browse/FOP-3269
>             Project: FOP
>          Issue Type: Bug
>            Reporter: Simon Steiner
>            Assignee: Simon Steiner
>            Priority: Major
>
> Generate pdf twice using -Xmx500m should not give OOM
> {code:java}
> public void xxx() throws Exception {
>     FopConfParser fopConfParser = new FopConfParser(new File("fop.xconf"),
>             new File("xxx").toURI());
>     FopFactoryBuilder fopFactoryBuilder = 
> fopConfParser.getFopFactoryBuilder();
>     fopFactoryBuilder.setStrictFOValidation(false);
>     FopFactory fopFactory = fopFactoryBuilder.build();
>     x(fopFactory);
>     fopFactory = fopFactoryBuilder.build();
>     x(fopFactory);
> }
> private void x(FopFactory fopFactory) throws Exception {
>     FOUserAgent userAgent = fopFactory.newFOUserAgent();
>     Transformer transformer = 
> TransformerFactory.newInstance().newTransformer();
>     Source src = new StreamSource(new FileInputStream("out.if"));
>     IFDocumentHandler documentHandler
>             = userAgent.getRendererFactory().createDocumentHandler(userAgent, 
> MimeConstants.MIME_PDF);
>     documentHandler.setResult(new StreamResult(new NullOutputStream()));
>     IFUtil.setupFonts(documentHandler);
>     IFParser parser = new IFParser();
>     Result res = new SAXResult(parser.getContentHandler(documentHandler, 
> userAgent));
>     transformer.transform(src, res);
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to