• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Island of isolation

 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?


Yours,
Bu.
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is 'Islands of Isolation' in garbage collection?
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
ready






Yours,

Bu.
 
reply
    Bookmark Topic Watch Topic
  • New Topic