https://issues.apache.org/bugzilla/show_bug.cgi?id=45653

           Summary: Tomcat leaks classloader reference, causing
                    java.lang.OutOfMemoryError: PermGen space
           Product: Tomcat 6
           Version: 6.0.18
          Platform: PC
               URL: NA
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: Catalina
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Tomcat leaks classloader reference, causing java.lang.OutOfMemoryError: PermGen
space

Sorry my bad English.
Tomcat version: 6.0.18, 6.0.14, looks like other versions suffer too.
Java: Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Problem: “java.lang.OutOfMemoryError: PermGen space” after several
redeployments of a custom web application
Cause: Tomcat does not clear a reference to WebappClassLoader used by
undeployed web applications. This reference is stored in field
contextClassLoader of a thread, used by tomcat. This thread is included in a
ThreadGroup. The ThreadGroup contains several dozens threads used by tomcat,
for shutdown hooks and other needs. This prevents WebappClassLoader of a
undeployed web applications to be collected. All Class’es, loaded by this
classloader are still in memory too.
Tomcat has to clean all references to undeployed WebappClassLoader.

How to reproduce:
A proof of concept simple web application. Of course, this app does nothing
with threads.
1. deploy this web application
2. undeploy this web app using Tomcat’s Manager
3. Force GC using jconsole
4. take a memory dump using jmap -dump:file=1.dmp 3740 (Tomcat’s process id
for Jps)
5. Open the memory dump in jhat 1.dmp
6. You will see, classes of undeployed web application are still in memory.
7. Using Jhat, find the classloader example used for web application
([EMAIL PROTECTED]
In the file attached)
8. Take a look at rootset references to this [EMAIL PROTECTED],
exclude WeakRefs
9. You can see a lot of links, preventing this [EMAIL PROTECTED] from
being collected. All links are ended in [EMAIL PROTECTED] (109
bytes) (field contextClassLoader:)

For example --> [EMAIL PROTECTED] (24 bytes)
(field catalinaDaemon:)
--> [EMAIL PROTECTED] (101 bytes) (field
shutdownHook:)
--> [EMAIL PROTECTED] (108
bytes) (field group:)
--> [EMAIL PROTECTED] (43 bytes) (field threads:)
--> [Ljava.lang.Thread;@0x33aeda0 (72 bytes) (Element 11 of
[Ljava.lang.Thread;@0x33aeda0:)
--> [EMAIL PROTECTED] (109 bytes) (field contextClassLoader:)
--> [EMAIL PROTECTED] (152 bytes)

Best regards


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to