Bug 39090 - Memory Leak: Tomcat files keep references to classes loaded by WebappClassLoader
Summary: Memory Leak: Tomcat files keep references to classes loaded by WebappClassLoader
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.5.9
Hardware: All Windows XP
: P2 major with 2 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 39631 40679 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-03-23 21:52 UTC by Kyrill Alyoshin
Modified: 2006-11-19 19:39 UTC (History)
3 users (show)



Attachments
Profiler Memory Leak Graph (6.14 KB, application/pdf)
2006-03-23 21:52 UTC, Kyrill Alyoshin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kyrill Alyoshin 2006-03-23 21:52:00 UTC
I am running Tomcat 5.5.15 on the latest J2SE 1.6 Mustang build 74. 

org.apache.tomcat.util.digester.Digester maintains references to commons-logging
log that gets loaded by WebappClassloader. See attached.

Thus, applications that put commons-logging.jar and log4.jar in their
WEB-INF/lib will not be GC'ed on reloads, undeploys, and stops. This is a severe
memory leak for developer's using Tomcat for development.

Please see the attachment from the YourKit Profiler that confirms this finding.

Note: it appears the last place in Tomcat's source code where this error occurs.
Once this is fixed, Tomcat will be fully "developer-friendly". :-)
Comment 1 Kyrill Alyoshin 2006-03-23 21:52:59 UTC
Created attachment 17960 [details]
Profiler Memory Leak Graph
Comment 2 Yoav Shapira 2006-04-13 19:42:58 UTC
Hmm.  It looks like the clear() and reset() methods (the latter calls clear())
set the log references to null.  What would you suggest?  An explicit finalizer
that calls clear() or reset() ?
Comment 3 Kyrill Alyoshin 2006-04-14 01:49:02 UTC
It seems like the code is pretty stable there. I'd suggest that the logger be
removed all together along with all log.info() and log.debug() statements in
that class. That should take care of it completely.

Kyrill

(In reply to comment #2)
> Hmm.  It looks like the clear() and reset() methods (the latter calls clear())
> set the log references to null.  What would you suggest?  An explicit finalizer
> that calls clear() or reset() ?
Comment 4 Grzegorz Grzybek 2006-06-19 13:34:12 UTC
*** Bug 39631 has been marked as a duplicate of this bug. ***
Comment 5 Rodrigo S de Castro 2006-09-05 12:58:37 UTC
I had exactly the same problem as described in bug #39090 when starting Tomcat
5.5.17:

java.lang.NullPointerException
   at org.apache.log4j.Category.isEnabledFor(Category.java:757)
   at
org.apache.commons.logging.impl.Log4JLogger.isTraceEnabled(Log4JLogger.java:327)

After replacing commons-logging.jar (1.1) with an older version (1.0.4), the
problem was gone. Before that I replaced log4j-1.2.13 with 1.2.8, but I still
had the problem.

This problem, in particular, does not seem to be related to Tomcat.
Comment 6 Mark Thomas 2006-11-19 19:37:43 UTC
This bug was listed as against 5.5.9 although the OP stated it was seen in 5.5.15.

Yoav's comment is dated after Remy's fix for 5.5.16
(http://marc.theaimsgroup.com/?l=tomcat-dev&m=114078110310583&w=2) was committed
hence his question regarding what else could/should be done since I am assuming
he was looking at SVN.

I have tested repeatedly reloading a web application and I cannot create this
memory leak (confirmed by analysing with YourKit). I am therefore resolving this
as fixed.

Comment 5 does not appear to be related to this issue. If this is still an
issue, a new bug report should be created.
Comment 7 Mark Thomas 2006-11-19 19:39:27 UTC
*** Bug 40679 has been marked as a duplicate of this bug. ***