You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Matt Magoffin <ap...@msqr.us> on 2008/03/12 20:29:16 UTC

Re: OutOfMemory errors; DTMManagerDefault.m_dtms contains13568 elements

>> What might create such a structure... a document without a root element
>> but referred to by 100,000 elements of <token>xyz</token>?
>
> Broken extension function?

I do use two extension functions that return a String instance each, and
another that returns an int. I don't use any extension functions that
return nodes. Would calling such functions end up creating <token>
elements in a DTM instance somewhere?


Re: OutOfMemory errors; DTMManagerDefault.m_dtms contains13568 elements

Posted by Matt Magoffin <ap...@msqr.us>.
>> I was looking in the org.apache.xalan.lib.ExsltStrings class, and every
>> call to tokenize references a cached static Document instance. Could
>> this
>> be causing all resulting all created Elements in every invocation of
>> tokenize() to get retained in the JVM forever? It almost seems as such,
>> given the number of these <token> elements piling up in my application's
>> heap.
> If it's cached at the Templates level, that's a bad implementation
> decision, since it not only has to be synchronized, but it will exist for
> as long as the Templates object exists.

I was trying to follow the code with what happens when the tokenize
function returns its new NodeSet (aka NodeList) instance of <token>
elements, and I think it goes into

new XNodeSetForDOM((org.w3c.dom.NodeList)val, xctxt);

new org.apache.xpath.NodeSetDTM(nodeList, xctxt);

xctxt.getDTMHandleFromNode(node);

DOM2DTM dtm = (DOM2DTM) getDTM(new javax.xml.transform.dom.DOMSource(root),
																		 false, null, true, true);

synchronized public void addDTM(DTM dtm, int id, int offset) (in
DTMManagerDefault)

So there is a new DOM2DTM instance for every NodeSet returned by this
function, and it would have been added to the DTMManager's m_dtm array.

But I can't see how that side-effect NodeSet turned DOM2DTM will
eventually be released by the DTMManager. Maybe it will never be, and
that's the problem?

So this is looking like I should find a way to not use the EXSLT tokenize
function in a long-running application. If anyone has any insight into
this effect, I'd greatly appreciate it.

-- m@




Re: OutOfMemory errors; DTMManagerDefault.m_dtms contains13568 elements

Posted by David Bertoni <db...@apache.org>.
Matt Magoffin wrote:
>>> Do you use any EXSLT string extension functions?  They create result
>>> tree
>>> fragments with token element nodes:
>>>
>>> http://exslt.org/str/functions/tokenize/index.html
>> Agh! Indeed there are some uses of that in some stylesheets, I missed it
>> in my previous searches. So... if that extension function is creating
>> these huge DTM documents, do you know if they ever get released? Or will
>> they hang around as long as I I hang on to a Templates object?
> 
> I was looking in the org.apache.xalan.lib.ExsltStrings class, and every
> call to tokenize references a cached static Document instance. Could this
> be causing all resulting all created Elements in every invocation of
> tokenize() to get retained in the JVM forever? It almost seems as such,
> given the number of these <token> elements piling up in my application's
> heap.
If it's cached at the Templates level, that's a bad implementation 
decision, since it not only has to be synchronized, but it will exist for 
as long as the Templates object exists.

Dave

Re: OutOfMemory errors; DTMManagerDefault.m_dtms contains13568 elements

Posted by Matt Magoffin <ap...@msqr.us>.
> Hi, Matt.
> Yes, that's almost certainly the problem.  This has previously been
> reported as Jira issue XALANJ-2215.[1]
>
> Thanks,
>
> Henry
> [1] https://issues.apache.org/jira/browse/XALANJ-2215

Ugh! Well, thanks everyone for helping get to the bottom of this. I've
removed all uses of the EXSLT tokenize function from our application's
XSLT.

-- m@



Re: OutOfMemory errors; DTMManagerDefault.m_dtms contains13568 elements

Posted by Henry Zongaro <zo...@ca.ibm.com>.
Hi, Matt.

"Matt Magoffin" <ap...@msqr.us> wrote on 2008-03-12 06:30:08 PM:
> >> Do you use any EXSLT string extension functions?  They create result
> >> tree
> >> fragments with token element nodes:
> >>
> >> http://exslt.org/str/functions/tokenize/index.html
> >
> > Agh! Indeed there are some uses of that in some stylesheets, I missed 
it
> > in my previous searches. So... if that extension function is creating
> > these huge DTM documents, do you know if they ever get released? Or 
will
> > they hang around as long as I I hang on to a Templates object?
> 
> I was looking in the org.apache.xalan.lib.ExsltStrings class, and every
> call to tokenize references a cached static Document instance. Could 
this
> be causing all resulting all created Elements in every invocation of
> tokenize() to get retained in the JVM forever? It almost seems as such,
> given the number of these <token> elements piling up in my application's
> heap.

Yes, that's almost certainly the problem.  This has previously been 
reported as Jira issue XALANJ-2215.[1]

Thanks,

Henry
[1] https://issues.apache.org/jira/browse/XALANJ-2215
------------------------------------------------------------------
Henry Zongaro
XML Transformation & Query Development
IBM Toronto Lab   T/L 313-6044;  Phone +1 905 413-6044
mailto:zongaro@ca.ibm.com

Re: OutOfMemory errors; DTMManagerDefault.m_dtms contains13568 elements

Posted by Matt Magoffin <ap...@msqr.us>.
>> Do you use any EXSLT string extension functions?  They create result
>> tree
>> fragments with token element nodes:
>>
>> http://exslt.org/str/functions/tokenize/index.html
>
> Agh! Indeed there are some uses of that in some stylesheets, I missed it
> in my previous searches. So... if that extension function is creating
> these huge DTM documents, do you know if they ever get released? Or will
> they hang around as long as I I hang on to a Templates object?

I was looking in the org.apache.xalan.lib.ExsltStrings class, and every
call to tokenize references a cached static Document instance. Could this
be causing all resulting all created Elements in every invocation of
tokenize() to get retained in the JVM forever? It almost seems as such,
given the number of these <token> elements piling up in my application's
heap.

-- m@



Re: OutOfMemory errors; DTMManagerDefault.m_dtms contains13568 elements

Posted by Matt Magoffin <ap...@msqr.us>.
> Matt Magoffin wrote:
>>>> What might create such a structure... a document without a root
>>>> element
>>>> but referred to by 100,000 elements of <token>xyz</token>?
>>> Broken extension function?
>>
>> I do use two extension functions that return a String instance each, and
>> another that returns an int. I don't use any extension functions that
>> return nodes. Would calling such functions end up creating <token>
>> elements in a DTM instance somewhere?
> Do you use any EXSLT string extension functions?  They create result tree
> fragments with token element nodes:
>
> http://exslt.org/str/functions/tokenize/index.html

Agh! Indeed there are some uses of that in some stylesheets, I missed it
in my previous searches. So... if that extension function is creating
these huge DTM documents, do you know if they ever get released? Or will
they hang around as long as I I hang on to a Templates object?

-- m@



Re: OutOfMemory errors; DTMManagerDefault.m_dtms contains13568 elements

Posted by David Bertoni <db...@apache.org>.
Matt Magoffin wrote:
>>> What might create such a structure... a document without a root element
>>> but referred to by 100,000 elements of <token>xyz</token>?
>> Broken extension function?
> 
> I do use two extension functions that return a String instance each, and
> another that returns an int. I don't use any extension functions that
> return nodes. Would calling such functions end up creating <token>
> elements in a DTM instance somewhere?
Do you use any EXSLT string extension functions?  They create result tree 
fragments with token element nodes:

http://exslt.org/str/functions/tokenize/index.html

Dave