Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
XSLT step leaks memory when a SaxonApiException is thrown on a stylesheet compile #108
XSLT step leaks memory when a SaxonApiException is thrown on a stylesheet compile
We are currently reusing the XPipeline instance for multiple executions with calls originating from a single JVM, however under certain error conditions we have experienced memory leaks. We have investigated further and found the culprit was in XLST.java
The previous collection resolver is restored after the stylesheet compile allowing the JVM to cleanup the above temporary created CollectionResolver:
However if an exception occurs during the stylesheet compile this step above is not performed leaving a new CollectionResolver in memory referencing the previous instance, this repeats for each subsequent execution leading to a large memory leak. Further analysis has shown another instance of this bug to be present is XQuery.java.
A quick workaround would be to move the statement config.setCollectionURIResolver(collectionResolver); into a finally block after the stylesheet compilation.