-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Konstantin,
On 11/6/12 2:59 PM, Konstantin Kolinko wrote: > 2012/11/6 Christopher Schultz <ch...@christopherschultz.net>: >> On 11/6/12 10:37 AM, Konstantin Kolinko wrote: >>> 2012/11/6 Christopher Schultz <ch...@christopherschultz.net>: >> >>> 2) I know of a bug in JVM when a certain kind of leak goes >>> undetected. I mean the leak through a shared Exception >>> instance and its native stacktrace. See >>> >>> https://issues.apache.org/bugzilla/show_bug.cgi?id=50460 >>> https://issues.apache.org/bugzilla/show_bug.cgi?id=53936 >>> (Linked from >>> https://wiki.apache.org/tomcat/MemoryLeakProtection) >> >> I don't create any of my own Exception objects that get shared. >> Could this be something introduced by Tomcat itself, or more >> likely some dependent library of mine? >> >> Since I can't readily trace the WebappClassLoader to its GC >> roots, do you have any suggestions for identifying the specific >> cause in my case? >> > > IIRC, I found that issue by looking for Exception objects that > were present in the memory. I was using Eclipse MAT. IIRC I > filtered the living objects by their class name. Okay, the good news is that there are very few objects with the word "Exception" in their name. Better still, many of them are classes like ExceptionHandler and thus not likely to be exceptions themselves. These are the actual Exception objects I can see: 3 instances of org.apache.tomcat.util.buf.UDecoder$DecodeException 1 instance of org.apache.tomcat.dbcp.dbcp.AbandonedTrace$AbandonedObjectException (I am using a Tomcat-configured JNDI DataSource) 1 instance of org.apache.naming.resources.ImmutableNameNotFoundException The few other Exception objects that I can see, I inspected and they said "no GC paths found" even when including soft/weak/finalizer references. Does that help at all? I can provide details about the GC paths for the above Tomcat-related exceptions if that helps. jdk1.7.0_09.jdk Tomcat 7.0.32 I realized when disclosing the Tomcat version that I had been running off Tomcat 7.0.x-trunk, so I have repeated my tests on Tomcat 7.0.32 with a bit more information: 1. Tomcat start 2. List applications in manager - no active sessions in main webapp 3. Reload target webapp 4. Find leaks: none reported 5. Reload webapp again 6. Find leaks again: none reported So far, so good. 7. Access protected page in target webapp (session is created), no authentication, yet (Tomcat redirects to login page, which invokes some Apache Struts routing code and a simple Velocity template) 8. Reload & find leaks: found a leak Performed 3 full GCs from within Yourkit, then took a memory snapshot for inspection. I see the aforementioned Exception objects in memory, but they all have o.a.c.loader.StandardClassLoader as their parent ClassLoader. Yourkit lists the following interesting memory tidbits: Objects unreachable from GC roots, but not yet collected: 68358 Objects reachable from GC roots via weak and/or soft references only: 35215 Objects pending finalization (finalizer queue objects unreachable via strong references): 288 It still looks like there is quite a bit of garbage laying around, even after 3 full GC requests (with a noticeable drop in memory usage when having performed my 3-GCs-in-a-row above, so the JVM isn't ignoring GC requests). Let's keep going. There's a session in memory. 9. Stop Tomcat (sessions are persisted to disk) 10. Start Tomcat (sessions are loaded from disk) 11. List Applications, confirm 1 active session 12. Inspect session. It contains the following objects: java.util.Locale A ClientPreferences object for our own application (basically a wrapper around Map<String,String>) 13. Reload, find leaks: found a leak So, it doesn't even require that I actually access a resource within my webapp: it is enough to have an active session. 14. Expire all sessions 15. Reload, find leaks: found *2* leaks 16. Stop Tomcat (no sessions persisted: all expired in step #14) 17. Start Tomcat 18. Reload, find leaks: none found So something my session loading triggers is causing the leak it seems. I'll take a closer look at the ClientPrefs class to see if there's anything odd going on in there. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iEYEARECAAYFAlCZevkACgkQ9CaO5/Lv0PCRmACfV22N21CSLqp6O+Y5i7kQ0ftc GNUAn01EXXhGfByIwoCZPcjocG0iC9hB =kXGO -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org