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 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 "Garbage Collection" Watch "Garbage Collection" New topic
Author

Garbage Collection

Aleix Vellozo
Greenhorn

Joined: Aug 23, 2006
Posts: 2
Hi all,

I am a bit confused with the answer for Question 3 on Dan Chilsholm website:
http://danchisholm.net/july21/topic/section3/gc1.html

Which old object is he referring to here, q1 was initially set to null before the loop, so at this point no objects are eligible for gc right?

Any comments on why the answer is 9, I would appreciate. Is it because all the 9 objects created will be eligible for gc when main() exit?

Cheers.....
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
There are 10 Q objects created by for loop.
"When the processing of line 2 begins", there are 9 objects eligible for GC and one is still hold by q1.
Aleix Vellozo
Greenhorn

Joined: Aug 23, 2006
Posts: 2
Thanks Wise,

I thought I had gc worked out but it seems not.

Why is the last object refereced by q1 not eligible for gc?

Cheers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage Collection
 
Similar Threads
Garbage Collection Problem Explain Pls Dan Chisholm single topic
Garbage collection...
A question from - danchisholm.net
danchisholm.net HashMap Question
GARBAGE COLLECTION (HFJ PG 266 )