Return-Path: X-Original-To: apmail-xalan-dev-archive@www.apache.org Delivered-To: apmail-xalan-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5FA6CDC44 for ; Fri, 26 Oct 2012 09:55:13 +0000 (UTC) Received: (qmail 12123 invoked by uid 500); 26 Oct 2012 09:55:13 -0000 Delivered-To: apmail-xalan-dev-archive@xalan.apache.org Received: (qmail 12094 invoked by uid 500); 26 Oct 2012 09:55:13 -0000 Mailing-List: contact dev-help@xalan.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@xalan.apache.org Delivered-To: mailing list dev@xalan.apache.org Received: (qmail 12051 invoked by uid 99); 26 Oct 2012 09:55:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Oct 2012 09:55:12 +0000 Date: Fri, 26 Oct 2012 09:55:12 +0000 (UTC) From: "Robert Olofsson (JIRA)" To: dev@xalan.apache.org Message-ID: <1816117399.31514.1351245312250.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (XALANJ-2195) Memory leak in XMLReaderManager MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/XALANJ-2195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13484821#comment-13484821 ] Robert Olofsson commented on XALANJ-2195: ----------------------------------------- That looks very interesting, maybe finally there will an official solution for this leak. > 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