Re: [xsl] How is memory allocated in recursive XSLT templates?

Subject: Re: [xsl] How is memory allocated in recursive XSLT templates?
From: "Rashmi Rubdi" <rashmi.sub@xxxxxxxxx>
Date: Wed, 2 May 2007 19:31:36 -0400
On 5/2/07, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> -Xss###k did not
> help anything, which makes me believe that the maximum
> recursive depth is enforced by Saxon somehow.
>

Initially I too thought -Xss didn't work, but it works on Saxon.


So I tried

java -Xss8192k -jar c:\dev\saxonb8-9-0-3j\saxon8.jar -it mainTemplate
recursion.xsl

with this stylesheet

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
			      xmlns:xs="http://www.w3.org/2001/XMLSchema";
			      xmlns:f="http://factorial.com/";>

<xsl:output omit-xml-declaration="yes"/>

<xsl:template name="mainTemplate">
 <xsl:value-of select="f:fac(10446)"/>	
</xsl:template>

<xsl:function name="f:fac">
     <xsl:param name="nr"/>
     <xsl:sequence select="if($nr = 0) then 1 else f:fac($nr -1) * $nr" />
</xsl:function>

</xsl:stylesheet>

and it gave the output similar to the Java Factorial program, however
I couldn't and didn't want to measure the time because the time
measurement is not precise anyway.


No, Saxon doesn't enforce any limit.


I'm not sure -Xss works in all environments. See for example

http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=4e8e9b5ea8255ffffffff
c30b7a19a079137:WuuT?bug_id=6316197

I tested the above on java version "1.6.0_01"


Please note that -Xss8192k is not the ~minimum~ required memory to run
the above factorial.

I think the minimum would be lower, but I still need to approximate it.

Michael Kay
http://www.saxonica.com/


-Regards Rashmi

Current Thread