xalan-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matteo TURRA (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (XALANJ-2195) Memory leak in XMLReaderManager
Date Fri, 26 Oct 2012 09:49:12 GMT

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

Matteo TURRA commented on XALANJ-2195:
--------------------------------------

I applied this patch but I run into lock in synchronized method (getXMLReader, releaseXMLReader).

I found this issue in this JBoss Enterprise Application Platform patch JBPAPP-7093: " In an
earlier release the caching behaviour in XMLReaderManager was removed to resolve a memory
leak. This forced each invocation to recreate the XMLReader and, as a result of the presence
of the Synchronized methods, contend with other threads. Caching has been reinstated through
the use of the SAXParser class, resolving the issue of thread contention. The original issue
of a memory leak is avoided by use of the SAXParser reset method."

See: https://issues.jboss.org/browse/JBPAPP-7093

                
> Memory leak in XMLReaderManager
> -------------------------------
>
>                 Key: XALANJ-2195
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2195
>             Project: XalanJ2
>          Issue Type: Bug
>          Components: Xalan
>    Affects Versions: 2.7
>            Reporter: Marko Strukelj
>            Priority: Blocker
>         Attachments: gc-roots.jpg, retained-object-sizes.jpg, xalan-j2-2.6.0-xmlmemoryleak-tm2l.patch
>
>
> In class org.apache.xml.utils.XMLReaderManager 
> getXMLReader() method creates a new XMLReader (i.e. SAXParser) and stores it into ThreadLocal.
> releaseXMLReader() does not remove (set to null) ThreadLocal thus creating a permanent
leak.
> Unfortunately the size of the cached Reader is typically dependent upon the size of the
XML document you process (depends on implementation but this is the case with xerces SAXParser).
In heavy load server environments with thread pools of tens and hundreds of threads the server
sustains a significant memory leak (hundreds of megabytes - depending on the XML document
sizes and number of threads in a thread pools).
> A fix is trivial:
> Put the following line at the end of releaseXMLReader method:
> m_readers.set(null);
> I wonder, why is reader stored in ThreadLocal in the first place?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

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


Mime
View raw message