[ https://issues.apache.org/jira/browse/XALANJ-2195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12530685 ]
Jörg von Frantzius commented on XALANJ-2195: -------------------------------------------- XMLReaderManager's only purpose seems to be that dreaded caching, as its first revision already contains it and the submit comment reads like this: 337775 04.12.2003 17:44:50 4 zongaro Moved code for caching XMLReader objects from XSLTC's TransformerFactoryImpl to a new org.apache.xml.utils.XMLReaderManager class. It is now the responsibility of the DTMManagerDefault class to request one of these cached XMLReader objects, so the benefit of reusing an XMLReader is now conferred upon both XSLTC and Xalan-J Interpretive, as well as upon references to the document() function. It seems that Xalan-Java 2.5.2 is the last version not containing this, according to http://xml.apache.org/xalan-j/history.html > 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 > > > 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. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]