Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 56204 invoked from network); 11 Feb 2009 12:53:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Feb 2009 12:53:45 -0000 Received: (qmail 46841 invoked by uid 500); 11 Feb 2009 12:53:34 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 46817 invoked by uid 500); 11 Feb 2009 12:53:34 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 46802 invoked by uid 99); 11 Feb 2009 12:53:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2009 04:53:34 -0800 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [193.252.22.151] (HELO smtp6.freeserve.com) (193.252.22.151) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Feb 2009 12:53:24 +0000 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf3508.me.freeserve.com (SMTP Server) with ESMTP id 988167000088 for ; Wed, 11 Feb 2009 13:53:01 +0100 (CET) Received: from smtp.homeinbox.net (unknown [91.109.142.188]) by mwinf3508.me.freeserve.com (SMTP Server) with ESMTP id 6C38C7000086 for ; Wed, 11 Feb 2009 13:53:01 +0100 (CET) X-ME-UUID: 20090211125301443.6C38C7000086@mwinf3508.me.freeserve.com Received: from localhost (localhost [127.0.0.1]) by smtp.homeinbox.net (Postfix) with ESMTP id B3F391A48B9 for ; Wed, 11 Feb 2009 12:52:50 +0000 (GMT) X-Virus-Scanned: Debian amavisd-new at homeinbox.net Received: from smtp.homeinbox.net ([127.0.0.1]) by localhost (server01.dev.local [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yGsC5qki32kC for ; Wed, 11 Feb 2009 12:52:44 +0000 (GMT) Received: from macbook.local (unknown [213.1.210.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.homeinbox.net (Postfix) with ESMTPSA id 441131A4255 for ; Wed, 11 Feb 2009 12:52:44 +0000 (GMT) Message-ID: <4992CA16.4000709@apache.org> Date: Wed, 11 Feb 2009 12:52:38 +0000 From: Mark Thomas User-Agent: Thunderbird 2.0.0.19 (Macintosh/20081209) MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Weblogic library and Tomcat References: <1234351627.15112.58.camel@localhost.localdomain> In-Reply-To: <1234351627.15112.58.camel@localhost.localdomain> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Pieter Temmerman wrote: > First of all, I'm not sure how I can figure out where the references to > the prior instances are being maintained, and secondly, I don't know how > to clean them up (both are closely related if you ask me :-) ) You are on the right track with a profiler. I use (and highly recommend) YourKit. I get a free copy as an Apache developer for investigating Tomcat related issues but it is reasonably priced and I have bought several copies for different projects over the years. It usually returns the investment on the first issue I fix. As to the why - image a scenario such as this. Tomcat starts Tomcat (for some reason) loads a JDBC driver The JDBC driver is registered with the driver manager Note: Tomcat has to load the DriverManager to do this Your webapp starts Your web app loads a JDBC driver Your web app registered the JDBC driver with the driver manager Your web app stops You have a huge memory leak. Why? Remembering that every class keeps a reference to the classloader that loaded it: DriverManager was loaded by Tomcat DriverManager has a reference to your JDBC driver Your JDBC driver has a reference to the web application classloader The web application class loader retains references to every class it has loaded Hence none of your classes are unloaded and Tomcat has an instance of your web application it can't garbage collect -> memory leak. Repeat this a few times and you'll get an OOM. As well as JDBC drivers, logging frameworks are frequent culprits for causing this. > My first thought was to take thread dumps, but there aren't showing up > any previous instances of the webapp. > > I don't have any experience with profilers, but I can try to use > VisualVM (which has a profiler-like tab) to take a look at all the > objects being instantiated. > Say I find any references to Weblogic, how should I go about having them > removed automatically each time the application is being redeployed? You need to find which objects are holding on to a reference to the the weblogic class and make sure it gets cleared when the app restarts. A context listener might be useful here. In the example above, you would need to remove the reference to your JDBC driver from the DriverManager. Profilers should provide utilities to trace references to instances of classes. HTH, Mark --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org