Article View: borland.public.jbuilder.java.language
Article #19858Re: Java Garbage Collection
From: jetball
Date: Wed, 10 Dec 1997 00:00
Date: Wed, 10 Dec 1997 00:00
37 lines
1484 bytes
1484 bytes
Hi Grzegorz,
Thanks for replying. I have ran your code and I'm not getting the "finalize
called" message at all.
Is this because of the JDK 1.1.2 or is it something that I have done wrong?
Binh. "jetball@usa.net"
Grzegorz Sliwinski wrote:
> If there are no more other references to any of these two objects (only
> circular), both of them get garbage collected.
> Try this:
> class Test1 {
> Test1 ref;
> protected void finalize() throws java.lang.Throwable{
> System.out.println("finalize called for: "+this+"->"+ref);
> super.finalize();
> }
> }
> class Test2 {
> static public void main(String[] args) {
> Test1 t1 = new Test1();
> t1.ref = new Test1();
> t1.ref.ref = t1;
> t1 = null;
> System.gc();
> }
> }
> Grzegorz Sliwinski
>
> jetball@usa.net wrote in message <348CF489.EC3AAD1@usa.net>...
> >My question is if I create two objects and have a circular reference to
> >them both. Will these two objects ever be destroyed by the garbage
> >collector?
Technical Details
Message-ID:
<348E057D.E1436C30@usa.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<348CF489.EC3AAD1@usa.net> <66kn7i$sr4@forums>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,7e35a16af36a1542 X-Google-Attributes: gidf74b3,public From: jetball@usa.net Subject: Re: Java Garbage Collection Date: 1997/12/10 Message-ID: <348E057D.E1436C30@usa.net> X-Deja-AN: 296791264 References: <348CF489.EC3AAD1@usa.net> <66kn7i$sr4@forums> To: Grzegorz Sliwinski <g.r.z.e.s.s@fast.com.pl> Organization: None Newsgroups: borland.public.jbuilder.java.language