jQuery in Action, 3rd edition
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Island of isolation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Island of isolation" Watch "Island of isolation" New topic

Island of isolation

Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 481

When the code reaches here, which 3 objects are GC?At line 6,i4.i refers to Island object and i2.i refers to island object,i3.i refers to island object.three objects(new Islands()) are already having object references(i2.i,i3.i,i4.i) refers to that.i2,i3,i4 are not objects.Those are object references.Then which three objects are eligible for GC here and how?Please help me.
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi Shiva,

Then which three objects are eligible for GC here and how?

I think:

I mean the three new Island-objects, not the references.
And I don't think, that this is an example of island of isolation. i2,3,4 are all nulled so all of their member variables (i) don't have an object which they could reference.
And no live thread can access these i2,3,4. So the three above are eligible for garbage collection.

Or am I wrong?


all events occur in real time
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
What is 'Islands of Isolation' in garbage collection?
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi Wise,

thank you for correcting me by providing the link.

I was wrong, this IS an example of an island of isolation.
Your nulling the "outer" islands. The member islands form an island of isolation, so GC can finalize the outer islands even though, there are references to them, but these are isolated.

I extended the code a bit, so it prints something:

Prints out: (VM dependent)
after line 6before calling System.gc
after calling gc
"when the code reaches here"before calling System.gc
Island 4 finalized
Island 3 finalized
Island 2 finalized
after calling gc


I agree. Here's the link: http://aspose.com/file-tools
subject: Island of isolation
It's not a secret anymore!