Return-Path: Delivered-To: apmail-incubator-harmony-dev-archive@www.apache.org Received: (qmail 45404 invoked from network); 1 Oct 2006 02:08:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 1 Oct 2006 02:08:57 -0000 Received: (qmail 93890 invoked by uid 500); 1 Oct 2006 02:08:50 -0000 Delivered-To: apmail-incubator-harmony-dev-archive@incubator.apache.org Received: (qmail 93841 invoked by uid 500); 1 Oct 2006 02:08:50 -0000 Mailing-List: contact harmony-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-dev@incubator.apache.org Received: (qmail 93830 invoked by uid 99); 1 Oct 2006 02:08:50 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 30 Sep 2006 19:08:50 -0700 Authentication-Results: idunn.apache.osuosl.org header.from=mrbillcollector@gmail.com; domainkeys=good X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 Received: from [66.249.82.238] ([66.249.82.238:45833] helo=wx-out-0506.google.com) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id 82/30-00407-E232F154 for ; Sat, 30 Sep 2006 19:08:47 -0700 Received: by wx-out-0506.google.com with SMTP id s13so1368389wxc for ; Sat, 30 Sep 2006 19:08:44 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=Tr8g4Rzkg8MJACPNegawZoAt1I/YGdvodSQGVhM5WcQ3n0lkUFYMOvSmY+ZcWKCQFAvZxS0Z4yQCeBwE/jLtQFlxgqhnAMzvAPhCOPXARB9eJo+ADhosYwRUO4PlhzYdUm86Xu/82fv9AAZrEM5IoJMYwkftPVdT5obHNuiiJjE= Received: by 10.90.63.16 with SMTP id l16mr2417038aga; Sat, 30 Sep 2006 19:08:44 -0700 (PDT) Received: by 10.90.68.17 with HTTP; Sat, 30 Sep 2006 19:08:43 -0700 (PDT) Message-ID: <50088f920609301908p3dd5f8bdt601a9c10edc5cc96@mail.gmail.com> Date: Sun, 1 Oct 2006 03:08:43 +0100 From: FaeLLe To: harmony-dev@incubator.apache.org Subject: Re: [General VM] GC strategy:how to garbage collect short-lived objects quickly. In-Reply-To: <12385bbd0609190910q585711fh45eeaac5f2eca33f@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_49422_29422619.1159668523943" References: <9623c9a50609140347l5d12486flea817b3f398c61bc@mail.gmail.com> <450EA5E2.1010700@googlemail.com> <9623c9a50609181722ncbae011m5a2505ff782ce3d@mail.gmail.com> <450FC142.9070503@googlemail.com> <450FCBD9.5000408@anu.edu.au> <450FFEC0.5050300@googlemail.com> <12385bbd0609190755r2a6c359ax8aecc0ec628e8043@mail.gmail.com> <4510101E.1000308@googlemail.com> <12385bbd0609190910q585711fh45eeaac5f2eca33f@mail.gmail.com> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_49422_29422619.1159668523943 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Perhaps he means clone the object to a WeakReference then null the original object ? That way the only existing copy of that object will be a WeakReference.... with my limited understanding of GC concepts would that no be benificial ? Regards, - Vikram Mohan On 9/19/06, Ivan Volosyuk wrote: > > On 9/19/06, Oliver Deakin wrote: > > Ivan Volosyuk wrote: > > > On 9/19/06, Oliver Deakin wrote: > > >> Robin Garner wrote: > > >> > > > >> >>> > > >> >>> I don't understand. How can weak references help short-lived > objects > > >> >>> reclaim? > > >> >> > > >> >> Really what I'm saying is that this is the closest thing we have > to a > > >> >> hint to GC that objects can be collected soon - but it is not > > >> anything > > >> >> like a proper free() call. There is no immediate reclaim of > memory, > > >> >> just the possibility that it will be reclaimed soon - and the > object > > >> >> may be garbage collected before you are finished with it! > > >> >> > > >> >> Regards, > > >> >> Oliver > > >> >> > > >> > > > >> > Actually, it's kind of the other way around isn't it ? Nulling the > > >> > last pointer to an object tells the GC that it can collect it > > >> > (explicitly in the case of reference counting), whereas having a > Weak > > >> > Reference to an object says 'please tell me when on-one else wants > > >> > this object', which results in the object staying around even > longer. > > >> > > >> Isn't this only the case if you register the WeakReference with a > > >> ReferenceQueue? > > >> If you do not do that, then the GC can collect the referent when it > > >> wants, and you will > > >> just get a null back from a get() call on any WeakReference object. > > >> So I imagine that keeping the object weakly reachable and not > > >> registering it with > > >> a ReferenceQueue says to the GC "you are free to collect this > referent > > >> object at the > > >> next collection if you wish". > > > > > > It is always better not to have any references to an object in heap > > > then to have a WeakReference to it. > > > > Yup, agreed! > > > > > The object without references is > > > simply garbage, while WeakReference is a kind of reference to it and > > > require handling - updating on object relocation, zeroing when object > > > no longer reachable. > > > > Agreed - but I wasn't comparing it to an object with no references. I > was > > merely saying that rather than having a strong reference to a very short > > lived object, that will definitely not be garbage collected until the > strong > > reference goes out of scope or is explicitly nullified, having only > > WeakReferences > > to the object could allow it to be collected ealier. I know it's not > > guaranteed, > > but there is a possibility. It's also probably not the best thing to do > > - it was > > just a comment on the ability to have short lived objects gc'ed earlier > :) > > Well, Oliver, if you have a strong reference to short-lived object, > you have it for a reason. This means that you do some actions with it. > It will be a failure when the reference to the object suddenly become > a null reference (what is normal for WeakReference). If you no longer > need that object - that means the live of it has just come to an end. > Short live :) > > After that, no more need for WeakReference to the object. Before that, > hard reference is required by the algorithm used. There is no place > here for WeakReference. > > May be I don't understand your point here. I don't see a way how > WeakReference can be used together with short lived objects. > > -- > Best regards, > Ivan > > --------------------------------------------------------------------- > Terms of use : http://incubator.apache.org/harmony/mailing.html > To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org > For additional commands, e-mail: harmony-dev-help@incubator.apache.org > > -- www.FaeLLe.com www.VikramMohan.com ------=_Part_49422_29422619.1159668523943--