You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "renaud michel (JIRA)" <xa...@xml.apache.org> on 2008/01/14 11:22:33 UTC

[jira] Commented: (XALANJ-2215) Extremely high memory usage (and OutOfMemory) when using EXSLT str:tokenize or str:split

    [ https://issues.apache.org/jira/browse/XALANJ-2215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12558561#action_12558561 ] 

renaud michel commented on XALANJ-2215:
---------------------------------------

We have the same problem here when using xalan in J2EE environment.
Tested with xalan 2.7.1 and xerces 2.9.

It looks like xalan creates an instance of org.w3c.dom.Document that is used to create new nodes. If the new nodes are used in the stylesheet they get linked to another Document and everything is fine. But (like in your exemple), if you do not used all the nodes (for exemple you tokenize but only need the first two parts) then the unused nodes seem to be still references by the document that created them, and that document is global for xalan.

Checked with xalan 2.7.1 in class org.apache.xalan.lib.ExsltStrings there is a static DocumentHolder.m_doc which is created once and will hold for the whole class lifetime (which may be equivalent to vm lifetime), thus if it keeps tracks of the nodes it created those will stay until vm end.

With such a problem, exslt strings extension are unusable in a J2EE environment.

> Extremely high memory usage (and OutOfMemory) when using EXSLT str:tokenize or str:split
> ----------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2215
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2215
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: Xalan-extensions
>    Affects Versions: 2.7
>         Environment: Tested on both:
> Windows XP Pro (Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing))
> and
> Redhat Linux (Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode))
>            Reporter: Michael Heinrichs
>         Attachments: test.zip
>
>
> There appears to be a severe memory usage issue when using the EXSLT functions str:tokenize or str:split as included in the latest version of Xalan (2.7.0, and also 2.6.1).  Even for relatively small XML files, when repeatedly using these functions, we are encountering OutOfMemory exceptions even with large (2GB) maximum heap sizes.  The code for these extension functions looks quite straightforward, so I suspect the problem lies deeper.
> I created a simple testcase to demonstrate the problem (see attached zip file).  Setting 1GB max heap, in this particular example (on Windows), I hit another exception (No more DTM IDs are available) before I reached OutOfMemoryError, but I imagine that if I tweak my example appropriately, I would hit OutOfMemory instead (on Linux, I get OutOfMemoryError).  This example XML contains 10,000 rows, and is ~312K.
> If I use the stylesheet version of the EXSLT function, I don't encounter this memory issue.
> Example command-line:
> > java -cp "C:\tmp\xalan-j_2_7_0\xalan.jar;C:\tmp\xalan-j_2_7_0\serializer.jar;C:\tmp\xalan-j_2_7_0\xml-apis.jar;C:\tmp\xalan-j_2_7_0\xercesImpl.jar" -Xmx1024m org.apache.xalan.xslt.Process -IN test.xml -XSL test.xsl -OUT test_out.xml
> This is the DTM-exception I get:
> file:///c:/tmp/test.xsl; Line #12; Column #61; XSLT Error (javax.xml.transform.TransformerException): No more DTM IDs are available Exception in thread "main" java.lang.RuntimeException: No more DTM IDs are available
>         at org.apache.xalan.xslt.Process.doExit(Process.java:1153)
>         at org.apache.xalan.xslt.Process.main(Process.java:1126)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org