ndw / xmlcalabash1

XML Calabash, an XProc processor
http://xmlcalabash.com/
108 stars 42 forks source link

Failed validation leads to memory leak #126

Closed ncrofts closed 11 years ago

ncrofts commented 11 years ago

While running pipelines using validate-with-xml-schema, we have found that exceptions thrown when the XML document fails to meet the schema cause a memory leak. In fact it would seem that in general if any processor throws an exception within a pipeline that a memory leak can result.

We have investigated the cause of this and it appears the leaks are being caused by a failure to clean up the data associated with the XProcData object. For example we have found several occurrences of the following sort of code:

XProcData data = runtime.getXProcData();
data.openFrame(this);

...calls a method that throws an exception e.g. xstep.run()

data.closeFrame();  // Does not get called after exception thrown, leading to a memory leak

It seems this pattern is repeated in several of the classes, including:

XAtomicStep.java XChoose.java XCompoundStep.java XPipeline.java

A workaround to this would be to move the closeFrame() call into a finally block.

Please let me know if any more information would be helpful.

ndw commented 11 years ago

Right you are. Fixed for the next release. (I'll close this bug after the fix is committed.)