aspose 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
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "garbage collection " Watch "garbage collection " New topic
Author

garbage collection

mrudul joshi
Ranch Hand

Joined: Nov 12, 2003
Posts: 54
11. Which statements about garbage collection are true?
A) The garbage collector runs in low memory situations
B) You can run the garbage collector when ever you want.
C) When it runs, it releases the memory allocated by an object.
D) Garbage collector immediately runs when you set the references to null.
The answers given are A and C, but I think we cannot predict when the garbage collector runs, so the answer should be only C.
Please clarify.
Thanks
Mrudul
Sagarika nair
Ranch Hand

Joined: Aug 13, 2003
Posts: 39
The K & B book states that the behavior when gc() is called may be different for different JVMs,so there is no guarantee that the unused objects will be removed from memory.
About the only thing you can guarantee is that if your program is running very low on memory , the garbage collector will run before it throws an OutOfMemoryException.
I hope that helps.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: garbage collection