File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage Collection doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage Collection doubt" Watch "Garbage Collection doubt" New topic
Author

Garbage Collection doubt

mamidi venkat
Ranch Hand

Joined: Jul 03, 2007
Posts: 63
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

Joined: Oct 15, 2007
Posts: 71
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

Joined: Jul 03, 2007
Posts: 63
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

Joined: Oct 15, 2007
Posts: 71
Yes object refered by x5 is eligible for Garbage Collection.
mamidi venkat
Ranch Hand

Joined: Jul 03, 2007
Posts: 63
Thanks for reply

i want to know one thing cleary objects are eligible for the garbage collection.
what about object reference and static members ???
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Garbage Collection doubt
 
Similar Threads
Garbage Collection
prob in grabage collector....?
Garbage collection
Garbage collection?
help on garbage collection (K &B's book Q)