Hi, Which of the follo stmts are true. 1.You can directly free the memory allocated by an object. 2.You can directly run the garbage collector whenever you want to and it will be schedule in due time.. 3.The garbage collector informs your object when it is about to be garbage collected. 4.The garbage collector reclaims an object’s memory as soon as it becomes a candidate for garbage collection. 5.The garbage collector runs in low-memory situations. the ans given are 2,3,5. I doubt the option 3 because it is unknown when an object would be garbage collected. Pl explain this. -Sanjana
How can the Option 2 be correct? My understanding is that, Garbage collection can only be suggested and it is at the sole discretion of the JVM to schedule the garbage collector in low-memory situations. Can any one explain on this? Thanks very much, Rama
2.You can directly run the garbage collector whenever you want to and it will be schedule in due time.
I believe this statement is wrong, because you can't directly run garbage collection, you simply request to run it, afterwards you'll have to wait for the JVM to honor your request. Eventhough the question says "it will be schedule in due time.", the term directly run is not accurate and should be changed to request to run.
- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!