Bug 51395 - First application that loads SAXParserFactory causes Class loader memory leak
First application that loads SAXParserFactory causes Class loader memory leak
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
7.0.14
PC Linux
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
: 51652 (view as bug list)
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2011-06-20 14:57 UTC by Arjen Knibbe
Modified: 2014-02-17 13:47 UTC (History)
1 user (show)



Attachments
Minimal web application with xercesImpl in lib (999.00 KB, application/octet-stream)
2011-06-20 15:07 UTC, Arjen Knibbe
Details
Minimal web application with xercesImpl in lib - second part (69.72 KB, application/octet-stream)
2011-06-20 15:08 UTC, Arjen Knibbe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Arjen Knibbe 2011-06-20 14:57:46 UTC
Overview
The class org.apache.catalina.startup.ContextConfig has an array of org.apache.tomcat.util.digester.Digester objects. Each Digester has a field factory to refer to a SAXParserFactory. If that SAXParserFactory is loaded via a WebappClassLoader, that WebappClassLoader is stuck in memory.

Steps to reproduce
Create a Web application that has xercesImpl.jar in its lib. (The Web application itself doesn't need to use any of the xerces classes.) Upload the application war file using Tomcat Manager. Verify that the application is loaded via Tomcat Manager -> List Applications

Restart Tomcat. Via Tomcat Manager -> List Applications, verify that the application is running. Undeploy the application. Click on Find leaks. The message above shows the application as leaking.

Make a memory dump using jmap, inspect the memory using jhat.
The WebappClassLoader for this application is still present. Its "reference chains from rootset" shows a chain like this:
Static reference from org.apache.catalina.startup.ContextConfig.webDigesters (from class org.apache.catalina.startup.ContextConfig) :
--> [Lorg.apache.tomcat.util.digester.Digester;@0x78be4958 (24 bytes) (Element 0 of [Lorg.apache.tomcat.util.digester.Digester;@0x78be4958:)
--> org.apache.tomcat.util.digester.Digester@0x78be3c50 (101 bytes) (field factory:)
--> org.apache.xerces.jaxp.SAXParserFactoryImpl@0x78bf0b28 (20 bytes) (??:)
--> class org.apache.xerces.jaxp.SAXParserFactoryImpl (84 bytes) (??:)
--> org.apache.catalina.loader.WebappClassLoader@0x78be3ea0 (165 bytes)
Comment 1 Arjen Knibbe 2011-06-20 15:07:59 UTC
Created attachment 27179 [details]
Minimal web application with xercesImpl in lib
Comment 2 Arjen Knibbe 2011-06-20 15:08:46 UTC
Created attachment 27180 [details]
Minimal web application with xercesImpl in lib - second part
Comment 3 Mark Thomas 2011-06-20 19:27:43 UTC
Thanks for the report. This has been fixed in 7.0.x and will be included in 7.0.17 onwards.
Comment 4 Mark Thomas 2011-08-12 09:14:55 UTC
*** Bug 51652 has been marked as a duplicate of this bug. ***