You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Dmitry Katsubo (JIRA)" <ji...@apache.org> on 2016/06/14 18:19:27 UTC

[jira] [Comment Edited] (XALANJ-2195) Memory leak in XMLReaderManager

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

Dmitry Katsubo edited comment on XALANJ-2195 at 6/14/16 6:18 PM:
-----------------------------------------------------------------

It's pity that the issue has been reported in 2005, and in 2016 still not in Xalan (I have checked [v2.7.2|http://grepcode.com/file/repo1.maven.org/maven2/xalan/xalan/2.7.2/org/apache/xml/utils/XMLReaderManager.java#XMLReaderManager.releaseXMLReader%28org.xml.sax.XMLReader%29]). What is more painful: build-in [JDK 7.40|http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java#XMLReaderManager.releaseXMLReader%28org.xml.sax.XMLReader%29] and [JDK 8.40|http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java#XMLReaderManager.releaseXMLReader%28org.xml.sax.XMLReader%29] Xalan is also affected by the problem.


was (Author: dma_k):
It's pity that the issue has been reported in 2005, and in 2016 still not in Xalan (I have checked [v2.7.2|http://grepcode.com/file/repo1.maven.org/maven2/xalan/xalan/2.7.2/org/apache/xml/utils/XMLReaderManager.java#XMLReaderManager.releaseXMLReader%28org.xml.sax.XMLReader%29]). What is more painful: build-in [JDK 7.40|http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java#XMLReaderManager.releaseXMLReader%28org.xml.sax.XMLReader%29] and [JDK 8.40|http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/8u40-b25/com/sun/org/apache/xml/internal/utils/XMLReaderManager.java#XMLReaderManager.releaseXMLReader%28org.xml.sax.XMLReader%29] Xerces are also affected by the problem.

> 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 was sent by Atlassian JIRA
(v6.3.4#6332)

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