wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes how many objects are eligible for GC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "how many objects are eligible for GC" Watch "how many objects are eligible for GC" New topic
Author

how many objects are eligible for GC

dolly shah
Ranch Hand

Joined: Jun 18, 2007
Posts: 383



Someone did post same post but I am not getting why c3 is not eligible for GC. I think c3 refers to c2.As soon as cb=null, c2 is null & c3=null.
Why Short wrapper object is eligible?

Can anyone please explain?


SCJP-1.5<br />SCWCD-1.4
Yeming Hu
Ranch Hand

Joined: May 14, 2007
Posts: 37
what is eligible for GC is object not reference variables. c3 has never point to an object. There are two objects of CardBoard type, each of which have a reference to a Short object. Therefore, There are 4 objects. c2 is not assigned to null although cb is because cb only have c2's value when c1.go(c2) is called. cb and c2 are defined in different methods. At last, there are only two objects are eligible for GC, one object of type CardBorad referenced by c1 originally (now c1 is null) and the other object of type Short referenced by the former object. These two objects are isolated island now


Best Wishes,<br /> Yeming
Manfred Klug
Ranch Hand

Joined: Jun 04, 2007
Posts: 377
Originally posted by Yeming Hu:
At last, there are only two objects are eligible for GC, one object of type CardBorad referenced by c1 originally (now c1 is null) and the other object of type Short referenced by the former object. These two objects are isolated island now
No. In this sample there is only one object eligible for garbage collection. For details have a look here.
Manfred Klug
Ranch Hand

Joined: Jun 04, 2007
Posts: 377
Originally posted by dolly shah:
As soon as cb=null, c2 is null
When you change cb, c2 does not change, since cb is a copy of c2. Have a look at Pass-by-Value Please. It may help you to get the concept.
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1526
You knew there is a thread already exisiting, it would have been better if you had continued there itself.
You tell us your understanding of what you know and what you expect the code or run, we can proceed ahead to get you along.


Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Originally posted by Akhilesh Trivedi:
You knew there is a thread already exisiting, it would have been better if you had continued there itself.
You tell us your understanding of what you know and what you expect the code or run, we can proceed ahead to get you along.


Yes, thats right. Many repeated-but-seems-like-duplicate threads are unnecessarily created and they can be avoided in that way!


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how many objects are eligible for GC
 
Similar Threads
object eligible for GC
Garbage collection
garbage collection?
eligible for GC
GC help