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
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.
Yes, my master! Here is the tiny ad you asked for:
a bit of art, as a gift, the permaculture playing cards