Bug #5607
closedSaxon-HE: Memory leak after migrating from version 10.X to version 11.X
100%
Description
Hi there, I recently upgraded an application from version 10.5 to version 11.3 of Saxon-HE and after the upgrade I'm seeing quite clearly a memory leak, so I'm wondering is there has been any change on the way templates should be handled with version 11.X, so I'm doing something wrong in my code now, or if if the bug is in Saxon-HE.
For context, I can reproduce the leak in my application 100% of the times, by simply swapping the Saxon-HE jar from one version to the other. No other change between tests. I have tested different versions from the 10.X branch and the 11.X and, as far as I have tested, no version 10.X suffers the issue and all versions 11.X do.
I have attached VisualVM snapshots (sorry, not sure if I can link them from the message) of some testing I have done with version 10.8 and version 11.3. The test requests some pages that are created by generating XML and then processing it with Saxon-HE. The loading and processing of the XSLTs is done by the Spring framework, so I'm not doing anything fancy with the templates.
Version 10.8 can run the whole test, about 15m , and if I then hit "force GC" memory goes back to normal levels. Version 11.3 explodes with an OOM before the 2m mark a Heap Dump before that showed me that there is a ton of memory being consumed by net.sf.saxon.expr.* classes, especially net.sf.saxon.expr.Operand.
Digging further, what I see is that I have a handful, 18, of compiled stylesheets that keep being reused and with version 11.3, it seems new Operands are being added and not cleaned. The GC path for Operand instances look like this one:
net.sf.saxon.expr.Operand#1 lhs in net.sf.saxon.expr.SlashExpression#1 body in net.sf.saxon.expr.instruct.GlobalVariable#1 [85] in java.lang.Object[]#330455 elementData in java.util.ArrayList#452544 globalVariables in net.sf.saxon.style.StylesheetPackage#61 topLevelPackage in net.sf.saxon.PreparedStylesheet#21 preparedStylesheet in net.sf.saxon.s9api.XsltExecutable#20 executable in net.sf.saxon.jaxp.TemplatesImpl#20 ... // Here it references one of the 18 Template instances that the application keeps
I have also done incremental heap dumps with some tests and the objects that grow from one dump to the next and never go down are mostly net.sf.saxon.expr.Operand instances.
So, any idea of some change that could be causing that? Any special handling that have to be performed now in the Templates objects to clean them?
Cheers! D.
Files
Please register to edit this issue