Project

Profile

Help

Bug #2339

closed

Very high memory usage when compiling xslt

Added by Bob Williams about 9 years ago. Updated almost 9 years ago.

Status:
Won't fix
Priority:
High
Category:
.NET API
Sprint/Milestone:
-
Start date:
2015-03-26
Due date:
% Done:

0%

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

Description

Hello:

We noticed RAM spikes over 1 GB when compiling xslt's using the Saxon .Net api. Also, the memory doesn't seem to be able to be reclaimed by our application. This will cause our application to crash after a period of time. It seems to be related to static XPath expression exceptions as shown in the screen shot.

How can we remove this memory footprint from the application?

What in the xslt may be causing this?


Files

XPathCompilationExceptions.png (32.9 KB) XPathCompilationExceptions.png Memory dump of static XPath expressions Bob Williams, 2015-03-26 22:44
nlm23dtd.zip (322 KB) nlm23dtd.zip DTD'S Bob Williams, 2015-03-27 14:58
nlm23xslt.zip (697 KB) nlm23xslt.zip XSLT'S Bob Williams, 2015-03-27 14:58
XslTransformation.cs (20.9 KB) XslTransformation.cs Class used for compiling. it's done in the constructor of the class. Bob Williams, 2015-03-27 15:00
Actions #1

Updated by O'Neil Delpratt about 9 years ago

  • Assignee set to O'Neil Delpratt

Hi Bob,

Thanks for reporting back to us the problem you are having. It is an interesting problem that we would like to explore further.

Firstly, the StaticError could be genuinely gathering errors in your stylesheet which are not failure errors, but just warnings. It would be good to inspect your stylesheet. Is it possible that you could send us your code, privately or on this bug issue?

Secondly, it would be good to eliminate the bytecode generation feature from this, which might be the cause of the high memory usage, please could you switch it off and run your program again to see if the issue goes away.

If you are running Saxon from the commandline just add the following option:

--generateByteCode:off

If you are running Saxon from C# code the following code. (I assume you have a processor object):

Processor processor = new Processor(true);
processor.SetProperty("http://saxon.sf.net/feature/generateByteCode", "false");

In Saxon 9.6 we have moved to the latest IKVM, which has better garbage collection for the object created using the bytecode generation feature for .NET. We have also made some improvements. It might be worth evaluating the latest release if my suggestions above fail to solve your problem.

It is possible that the bottle neck is somewhere else. Could you please send us some more details of the memory dump?

Actions #2

Updated by Bob Williams about 9 years ago

Hi:

Attached, please fin the style sheets, DTD'S and a C# class we use to compile the xslt.

We are currently already turning off the byte code.

I will try to get more info on the memory dump.

Actions #3

Updated by O'Neil Delpratt about 9 years ago

  • Status changed from New to In Progress

Hi,

sorry for the delay in getting back to you. I am trying to create a repo with the C# code and stylesheets you sent last week, but it seems like I need some other libraries to run your code. Specifically I am not sure where to find WKHMR.

Actions #4

Updated by Bob Williams about 9 years ago

We have seen that during compilation we saw the following issues causing some of the compiler exceptions.

The root cause of the compilation errors is the fact that we are running an XSLT function from an attribute, then expecting the attribute node to contain attributes. The specific code is listed below and is peppered throughout our mappings in various formats.

Bad

@xlink:href/my:externalLinkRef(@xlink:href,@xlink:format,@xlink:title, @xlink:type,@xlink:label, @xlink:role)

Good

@xlink:href/my:externalLinkRef(../@xlink:href,../@xlink:format,../@xlink:title, ../@xlink:type,../@xlink:label, ../@xlink:role)

We also noticed that the some of the xslt files are over 15 MB is size which takes 300 MB of RAM to compile. So in the short term we have cleaned up the xslt's a bit for the aforementioned issue, removed the ErrorsList property assignment in the compiler object and forced a .Net garbage collection on gen 2 and 0 after compilation. After the garbage collection the memory is getting cleared. I think you said 9.6 has more optimized garbage collection for the IKVM which is something we should investigate.

Actions #5

Updated by O'Neil Delpratt almost 9 years ago

  • Status changed from In Progress to Won't fix

Hi,

Glad to know that you have sorted out your memory issues in your XSLT. Therefore I am closing this bug issue as won't fix.

Any other problems please let us know.

Please register to edit this issue

Also available in: Atom PDF