• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Garbage Collection doubt

 
mamidi venkat
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

X3 x2 = new X3();
X3 x3 = new X3();
X3 x5 = x3;
x3 = x2;
X3 x4 = x3;

Question
x5->x3
x3->x2

Can any one explains me what happens with x5 here is x5 is deleted
because x3 having the reference of x2 or x5 is holding the reference of x3



 
Kishore Kumar
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here None of the object is garbage collected.

x5 is pointing to the object which was created by x3 reference previously.
 
mamidi venkat
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply

i want to know one thing cleary objects are eligible for the garbage collection.what about object reference and static members

x5->x3
x3->x2
x5=null

now x5 is elibigle for the GC right
 
Kishore Kumar
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes object refered by x5 is eligible for Garbage Collection.
 
mamidi venkat
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply

i want to know one thing cleary objects are eligible for the garbage collection.
what about object reference and static members ???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic