Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Islands of Isolated Objects (IIO)

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody:
My final day for SCJP has come. Tomorrow is the day. I'm nervous but confident. To he point: I don't understand the meaning of "Islands of Isolated Objects". How can I know when an IIO is elegible for garbage collected?
Thanks,

Enrique Villamizar
P.S. English isn't my first language.
 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
They are eligible for garbage collection when they are not referred to by anything other than each other.

For example, say you have an object a, which nothing refers to. That's available for GC, right? If b refers to a, then a is not available for GC. However, what if the only reference to a is from b, and the only reference to b is from a? Then a and b represent an "island", and should both be garbage collected.
 
Enrique Villamizar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Greg!

after line 9 runs, how many objects are elgible for garbage collection?
At first I thought none. But the answers is two. What happens for example with x2.x and x3.x? they are objects too, aren't they? To be honest I don't understand this K&B question.

Enrique Villamizar
P.S. English isn't my first language.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The objects created in the first two lines of main method will be GC'd.
X2 x2 = new X2();
X2 x3 = new X2();

Even though these both object have references between each other, these objects will be GC'd because "these two objects cannot be reached from any of the threads in jvm". If they cannot be reached, why they should be there ? So they will be GC'd.
 
No, tomorrow we rule the world! With this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic