XSLT step leaks memory when a SaxonApiException is thrown on a stylesheet compile #108

Closed
rama-nallamilli opened this Issue Jul 5, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@rama-nallamilli

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

    config.setCollectionURIResolver(new CollectionResolver(runtime, defaultCollection, collectionResolver));

The previous collection resolver is restored after the stylesheet compile allowing the JVM to cleanup the above temporary created CollectionResolver:

    config.setCollectionURIResolver(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.

ndw added a commit that referenced this issue Jul 26, 2013

ndw added a commit that referenced this issue Jul 26, 2013

@ndw

This comment has been minimized.

Show comment
Hide comment
@ndw

ndw Jul 26, 2013

Owner

I think that does it. Let me know if you find I'm mistaken.

Owner

ndw commented Jul 26, 2013

I think that does it. Let me know if you find I'm mistaken.

@ndw ndw closed this Jul 26, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment