Project

Profile

Help

Bug #5607

closed

Saxon-HE: Memory leak after migrating from version 10.X to version 11.X

Added by Daniel Lopez almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Performance
Sprint/Milestone:
-
Start date:
2022-07-15
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
11, trunk
Fix Committed on Branch:
11, trunk
Fixed in Maintenance Release:
Platforms:

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

Version_10.8.png (74.1 KB) Version_10.8.png Daniel Lopez, 2022-07-15 13:01
Version_11.3.png (115 KB) Version_11.3.png Daniel Lopez, 2022-07-15 13:01
Version_11.3_HeapDump.png (121 KB) Version_11.3_HeapDump.png Daniel Lopez, 2022-07-15 13:01
LeakTest-202207181355-heapdump.hprof (876 MB) LeakTest-202207181355-heapdump.hprof Daniel Lopez, 2022-07-18 14:01
SaxonTest.zip (100 KB) SaxonTest.zip Daniel Lopez, 2022-07-18 18:04
SaxonTest_fixed.zip (99.3 KB) SaxonTest_fixed.zip Daniel Lopez, 2022-07-19 08:12

Please register to edit this issue

Also available in: Atom PDF