We are using Saxon-B 8.7.3 in our web application and we recently ran into a few OutOfMemory errors. Using the eclipse plugin Memory Analysis Tool, we tracked down where the memory was being used mostly and we found out that a few of our classes using compiled stylesheet were growing very big.

After transforming different XML sources that are relatively big (a few MB), the compiled stylesheet grows in size and the memory is never released, generating an OutOfMemory error. The Memory Analysis tool allowed us to drill down the objects and it looks like the compiled stylesheet has a Configuration object that stores a list of ContentHandlers in a field called sourceParserPool. In our case, this list contains a SAXParserImpl.JAXPSAXParser which has a ReceivingContentHandler that has a reference to a TinyTree object containing the source XML (or parts of it). This TinyTree object is the object that holds most of the memory and that grows in size each time a new source XML is parsed with that compiled stylesheet.

We can provide more details if needed but we were wondering if we are maybe doing something wrong when creating the stylesheet (very basic creation: TransformerFactory.newInstance().newTemplates(source)), or if this TinyTree object should not be referenced anymore at this stage and therefore it's a bug that has been fixed in later versions.

Thanks for the help,

Jean-Baptiste Reure