Dear FOP developers,

it seems that there is significant memory leaks in FOP. There must be some
static structures which keep collecting objects. Attached is a simple java
program, which converts readme.fo -> readme.pdf 100 times in a row. The loop
looks like this (see the whole program as an attachment): This loop eats
about 2 MB of memory each iteration. It also slows down after few dozen
iterations.

for (int i=0 ; i<iterations; i++)
{
        // RUN WITH
        // java -mx200m -ms200m FOPMemoryTest  to get the same total memory thru
        // iterations
        long totalmem=Runtime.getRuntime().totalMemory();
        long allmem=totalmem-Runtime.getRuntime().freeMemory();
        System.out.println(i+"th Iteration. Total mem:"+totalmem+" Allocated mem:
"+allmem +" ("+allmem/1000000+" MB)"
                );
    driver.buildFOTree(parser, inputHandler.getInputSource());
    driver.format();
    driver.setOutputStream(new FileOutputStream(new File(outfilename)));
    driver.render();
        driver.reset();
        System.gc();
}
As output I get:

java -mx200m -ms200m FOPMemoryTest
using SAX parser org.apache.xerces.parsers.SAXParser

0th Iteration. Total mem:209453056 Allocated mem: 3169192 (3 MB) building
formatting object tree
setting up fonts
formatting FOs into areas
 [1] [2] [3] [4] [5] [6] [7>>] [8] [9]
rendering areas to PDF
writing out PDF
1th Iteration. Total mem:209453056 Allocated mem: 3769128 (3 MB) building
formatting object tree
setting up fonts
formatting FOs into areas
 [1] [2] [3] [4] [5] [6] [7>>] [8] [9]
rendering areas to PDF
writing out PDF
2th Iteration. Total mem:209453056 Allocated mem: 5964480 (5 MB) building
formatting object tree
setting up fonts
formatting FOs into areas
 [1] [2] [3] [4] [5] [6] [7>>] [8] [9]
rendering areas to PDF
writing out PDF
3th Iteration. Total mem:209453056 Allocated mem: 8200096 (8 MB)
...
4th Iteration. Total mem:209453056 Allocated mem: 9909016 (9 MB)
5th Iteration. Total mem:209453056 Allocated mem: 12145736 (12 MB)
6th Iteration. Total mem:209453056 Allocated mem: 14390920 (14 MB)
......
35th Iteration. Total mem:209453056 Allocated mem: 83965480 (83 MB)
39th Iteration. Total mem:209453056 Allocated mem: 89258336 (89 MB)
46th Iteration. Total mem:209453056 Allocated mem: 103850600 (103 MB)
54th Iteration. Total mem:209453056 Allocated mem: 114726192 (114 MB)
...

Or am I doing something illegal here?

Regards,

        Mikko Honkala - http://www.x-smiles.org/

FOPMemoryTest.java

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

Reply via email to