wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubt in Garbage Collector 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 "Doubt in Garbage Collector" Watch "Doubt in Garbage Collector" New topic
Author

Doubt in Garbage Collector

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Hi Ranchers,

Consider the following code and please tell me why only 3 objects are garbage collected?



Anyone please help me with this. When run as
>java finalizers 5 500000....please interpret me the result? Thanks early for your answers.

Regards,
Jothi Shankar Kumar. S


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

All objects need not necessarily be garbage collected. The output will be different in different environment settings. In my system 4 objects were garbage collected. There is no guarentee that all unnecessary objects will be GCed.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

Hi above,

So what to do when I get such questions asking for how many objects will be garbage collected considering the above code. I too know that the gc is totally under the control of JVM. Please can anyone give me ideason what to concentrate and on what not to for the scjp 1.4, Garbage collectors topic.

Regards,
Jothi Shankar Kumar. S
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

You can select the option "Cannot be determined".
 
 
subject: Doubt in Garbage Collector
 
Similar Threads
Cannot understand the following GC example from Khalid Mughal
confused with gc
GC
garbage collection
Finalize()