Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 8628 invoked from network); 3 May 2006 14:33:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 May 2006 14:33:36 -0000 Received: (qmail 56768 invoked by uid 500); 3 May 2006 14:32:36 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 56736 invoked by uid 500); 3 May 2006 14:32:35 -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 56725 invoked by uid 99); 3 May 2006 14:32:35 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 May 2006 07:32:35 -0700 X-ASF-Spam-Status: No, hits=1.3 required=10.0 tests=RCVD_IN_BL_SPAMCOP_NET,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of rosenberg.leon@googlemail.com designates 64.233.184.234 as permitted sender) Received: from [64.233.184.234] (HELO wr-out-0506.google.com) (64.233.184.234) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 May 2006 07:32:35 -0700 Received: by wr-out-0506.google.com with SMTP id i22so141458wra for ; Wed, 03 May 2006 07:32:14 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=googlemail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=C/duyBUDjJFmumj1ca87AsAbvIKouVHYN7RO+nfxLXnmp904As0sS9fWMOOVhl5Dnwl+wBF6L643Lt3Ov5MbN8IrTAIPr+3vKwrTLQS9Kb4E0H5JO5iVfxp/0NhZ+55knqmWdLyWjFcXdPfC3Yn3hg02AQfBPg6PaykSx38J3V4= Received: by 10.65.51.10 with SMTP id d10mr1127698qbk; Wed, 03 May 2006 07:32:14 -0700 (PDT) Received: by 10.65.97.10 with HTTP; Wed, 3 May 2006 07:32:13 -0700 (PDT) Message-ID: <327858f40605030732y3c4f35aci17d5ea571865db9d@mail.gmail.com> Date: Wed, 3 May 2006 16:32:13 +0200 From: "Leon Rosenberg" To: "Tomcat Users List" Subject: Re: Servlet inter-communication In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On 5/3/06, Peter Crowther wrote: > > From: Leon Rosenberg [mailto:rosenberg.leon@googlemail.com] > > Could you explain it a bit more? What's the difference whether I have > > 10 instances of the same class or just one for reloading? > > In a Singleton: > > - the class holds a reference to the classloader; > > - the class holds a reference to the singleton instance; > > - the instance holds a reference to the class. > > My understanding is that classes cannot be GCed unless they have no > instances, and classloaders are (obviously) not collected until they > have no references from classes. So singletons leave classes lying > around in your JVM. More annoyingly, classes always occupy PermGen > space, so this junk class is now eating up precious space in PermGen - > hence the possibility of an OOME if you reload your webapp too many > times. The solution is to implement appropriate listeners to make sure > the instance is not referenced by the class before the webapp is > unloaded. > > That's a quick recap from memory. I thoroughly expect Chuck to jump > into the conversation and point out where I've misinterpreted :-). Ok, what you mean is, that the "instance" variable of the singleton is static, and therefore can't be collected, because the class references the object and the object references the class. I don't think that the classloader plays a role here. Shouldn't the gc be able to resolve cyclic references? Even if it doesn't, is this a real problem? I mean reloading a webapp in production environment is a greater nogo than using a singleton, isn't it? regards Leon > > - Peter > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org