[
http://issues.apache.org/jira/browse/XALANJ-2195?page=comments#action_12418300
]
Eric Burke commented on XALANJ-2195:
------------------------------------
The hack/fix I posted earlier can lead to NullPointerException. I added this
line to the start of the method:
if (reader == null) {
return;
}
I realize this is a hacky workaround; sorry I don't have time to investigate a
more solid fix. We've been running in production all day now, and with this fix
(in addition to the code I listed in an earlier comment) the leak is gone.
> Memory leak in XMLReaderManager
> -------------------------------
>
> Key: XALANJ-2195
> URL: http://issues.apache.org/jira/browse/XALANJ-2195
> Project: XalanJ2
> Type: Bug
> Components: Xalan
> Versions: 2.7
> Reporter: Marko Strukelj
> 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.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]