xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Delmelle <andreas.delme...@telenet.be>
Subject Re: Fop 0.20.5 vs Fop Trunk Performace
Date Wed, 05 Mar 2008 22:06:54 GMT
On Mar 5, 2008, at 21:36, Andreas Delmelle wrote:

> On Mar 5, 2008, at 21:09, Puppala, Kumar (LNG-CON) wrote:
>>
>>            // Setup JAXP using identity transformer
>>            TransformerFactory factory =  
>> TransformerFactory.newInstance();
>>            Transformer transformer = factory.newTransformer(); //  
>> identity transformer
>
> Interesting! So the memory leaks are not inherent to FOP it would  
> seem, but to the way the JAXP-pattern is used.
>
>>
>> When you use the TransformerFactory in this manner (within each  
>> run), the SAXParser instance created by the transformer is held in  
>> memory. On subsequent runs, I noticed more and more instances of  
>> SAXParser’s in memory. To fix this, I moved this code to the  
>> calling function, thus keeping a single copy of transformer.
>
> Makes sense. The TransformerFactory should indeed (better practice)  
> be declared only once. If you ever plan on using XSLT stylesheets,  
> you could also cache a Templates object.

This made me re-read the API docs, and it this may suit your  
particular setup, I was wrong and in general one should actually be  
*very* careful when re-using either the TransformerFactory or the  
Transformer. Neither of the objects are thread-safe, so this can only  
be done if you are absolutely certain that no two threads will  
concurrently access either of them... Re-using them in sequence is no  
problem whatsoever, and actually seems to be recommended, based on  
your observations.



Cheers

Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message