• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collection.....

 
G Nadeem
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
this may b primitive but .....plz help.
1. public void whereEligible(){
2. Object v = new Object();
3. Object b;
4. v = null;
5. b = v;
6. }
does the variable become elligible immediatly after line 4 because of being nullified OR does it not because of active reference at line 5?
thanks.
 
Lawrence Chettiar
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well Nadeem,
The object which was referenced by variable v is eligible for garbage collection after line 4, what you are using at line 5 is the reference variable and not the object referenced at line 2.
Hope this makes things clear.
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nadeem
does the variable become elligible immediatly after line 4

Vairables are not garbage collected its the Object they are refering is collected. So object reffered by v may be garbage collected and not v itself.
[ June 04, 2003: Message edited by: Anupam Sinha ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic