Will Garbage Collector be called immediately, once an object is ready to be freed (once object doesn't have any references)?
No, it takes some time to GC to trigger and reclaim the memory of un referenced objects in the heap.
Yes, GC will be triggered immediately to reclaim the memory of un referenced objects in the heap.
There is no guarantee as such. That depends on GC logic of that JVM.
There is no guarantee that JVM will trigger GC to reclaim memory of unreferenced objects in the heap, immediately. Sun documentation also doesn't specify any thing about it. So it is left to JVM internal GC logic.
That means, if there is any object in the heap with out any references, there is no guarantee that Garbage Collector will clean it immediately once the last reference is removed. The reason for this is running a Garbage Collector to clean the heap memory is a tedious and time consuming process. It may halt and slow down the CPU some time. That's why it will be started only if there is really less memory.
Back To Top