You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2008/08/19 17:50:40 UTC

DO NOT REPLY [Bug 45653] New: Tomcat leaks classloader reference, causing java.lang.OutOfMemoryError: PermGen space

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: tomcat-dev@jakarta.apache.org
        ReportedBy: philip75_t@hotmail.com


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
(org.apache.catalina.loader.WebappClassLoader@0x31337a0
In the file attached)
8. Take a look at rootset references to this WebappClassLoader@0x31337a0,
exclude WeakRefs
9. You can see a lot of links, preventing this WebappClassLoader@0x31337a0 from
being collected. All links are ended in java.util.TimerThread@0x34962c0 (109
bytes) (field contextClassLoader:)

For example --> org.apache.catalina.startup.Bootstrap@0x2eb2310 (24 bytes)
(field catalinaDaemon:)
--> org.apache.catalina.startup.Catalina@0x2ec6bd0 (101 bytes) (field
shutdownHook:)
--> org.apache.catalina.startup.Catalina$CatalinaShutdownHook@0x33c0018 (108
bytes) (field group:)
--> java.lang.ThreadGroup@0x2eb1f40 (43 bytes) (field threads:)
--> [Ljava.lang.Thread;@0x33aeda0 (72 bytes) (Element 11 of
[Ljava.lang.Thread;@0x33aeda0:)
--> java.util.TimerThread@0x34962c0 (109 bytes) (field contextClassLoader:)
--> org.apache.catalina.loader.WebappClassLoader@0x31337a0 (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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 45653] Tomcat leaks classloader reference, causing java.lang.OutOfMemoryError: PermGen space

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45653





--- Comment #1 from Philip Zuev <ph...@hotmail.com>  2008-08-20 10:52:33 PST ---
Created an attachment (id=22462)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=22462)
Jhat memory report

Jhat memory report


-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 45653] Tomcat leaks classloader reference, causing java.lang.OutOfMemoryError: PermGen space

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=45653


Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #2 from Mark Thomas <ma...@apache.org>  2008-08-20 16:30:56 PST ---
This is a caused by coding errors in your test application and/or bugs in the
libraries you are using. Please ask on the users list if you need further
assistance.


-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org