• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Isolating Reference..

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
Isolating reference which is one of the way that an object becomes eligible for garbage collection can anyone explain me the exact meaning of this method with an example.

Thanks in advance..
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An object is considered eligible for Garbage Collection when no reachable variable refers it.

Public Class Isolation {
Isolation i
public static void main(String[] args) {
Isolation a = new Isolation()
Isolation b = new Isolation()
a.i = b;
b.i = a;

a = null;
b = null;
}
}

In this situatio the objects a and b are referred by b.i and a.i instance variables. However after assigning a and b to null, a.i and b.i become unreachable and inspite of having a reference varible, they are made eligible for GC because these objects can no longer be accessed by the program any longer.
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Preetha,

the below link discussed about the same

https://coderanch.com/t/251683/java-programmer-SCJP/certification/Garbage-Collection

you may want to look at this.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic