🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #560

Re: Reference and Garbage Collection

#560
From: Alexey N. Solofnenko
Date: Tue, 05 Jul 2005 06:28
53 lines
2425 bytes
Yes and no. A reference to Child1 object will lock NeverRelease object 
in memory, but I found few times that [at least some] Borland compilers 
pass null, if the parent object is not used, so there is no real 
difference, if JBuilder compiler is used. Please never define exceptions 
(and any Serializable classes) this way, the extra reference will force 
too many objects to be serialized.

- Alexey.

Vander wrote:
> I'm not quite sure about what kind of references to an object determine 
> its "alive" quality and its readiness for garbage collection. For the 
> moment I understand that *any* living reference, including non-explict 
> of member classes, keep the object alive.
> 
> Would you agree that the follwoing class "NeverRelease" entails 
> instances which will never get prone to garbage collection?
> 
> class NeverRelease
> {
>    Child1    child;
> 
>    public NeverRelease ()
>    {
>       child = new Child1();
>    }
> 
>    private class Child1
>    {
>    }
> }
> 
> While would you also agree that instances of the following class 
> "AlwaysRelease" always become garbage because the member class is static 
> and hence does not take reference to the enclosing class?
> 
> class AlwaysRelease
> {
>    Child2    child;
> 
>    public AlwaysRelease ()
>    {
>       child = new Child2();
>    }
> 
>    private static class Child2
>    {
>    }
> }

-- 
Alexey N. Solofnenko
home: http://trelony.cjb.net/
Technical Details
Message-ID: <42ca2885$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42ca2130$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,afdd6d6a52ac0c35
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Mon, 04 Jul 2005 23:28:24 -0700
From: "Alexey N. Solofnenko" <nospam@nospam.comp>
User-Agent: Mozilla Thunderbird 1.0+ (X11/20050703)
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: Reference and Garbage Collection
References: <42ca2130$1@newsgroups.borland.com>
In-Reply-To: <42ca2130$1@newsgroups.borland.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 67.188.247.45
Message-ID: <42ca2885$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1120544901 67.188.247.45 (4 Jul 2005 23:28:21 -0700)
Lines: 53
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail