Bug 36558 - IntrospectionUtils caches application classes
IntrospectionUtils caches application classes
Status: RESOLVED FIXED
Product: Tomcat 5
Classification: Unclassified
Component: Catalina
5.5.9
All All
: P2 normal with 1 vote (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2005-09-08 15:28 UTC by Magnus Alvestad
Modified: 2005-09-08 09:42 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Alvestad 2005-09-08 15:28:52 UTC
The class org.apache.tomcat.util.IntrospectionUtils caches the methods of 
classes used as parameters to the findMethods() method.  This cache has hard 
references, so when used against an application class (often an exception), the 
classloader of that application will never be unloaded.

Notice that changing the cache to a WeakHashMap would not help, as the class 
reference is also inside the Method object stored in the value field.

I think the same class (IntrospectionUtils) exists in the commons-modeler 
library, with the same problem.
Comment 1 Magnus Alvestad 2005-09-08 15:42:08 UTC
There is more information about the general problem of not being able to GC 
class loaders at this wiki page:

http://opensource2.atlassian.com/confluence/spring/pages/viewpage.action?
pageId=2669
Comment 2 Remy Maucherat 2005-09-08 16:30:38 UTC
The commons-modeler IntrospectionUtils should not be a problem for regular
Tomcat operation. However, I see org.apache.tomcat.util.IntrospectionUtils is
indeed used on exceptions that come out of the web application, so there is a
problem for custom exception types.

I will add a clear method to org.apache.tomcat.util.IntrospectionUtils as
conserving the cache seems necessary.
Comment 3 Remy Maucherat 2005-09-08 17:42:39 UTC
I added a clear method which is called when stopping the classloader, so the
issue is fixed in org.apache.tomcat.util.IntrospectionUtils.