This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
well, technically speaking, System.gc() would call the Runtime().gc() which would pass on the implementation as native to the JVM. So, in short, its all upto the JVM vendor and his choice of implementation how the garbage collection would work...
The main objective of Garbage Collector is to destruct the useless objects. Garbage Collector is a DeamonThread and it always running in the background with low thread priority. If an object doesnt have any reference variable then it always eligible for GC( some times even though object having reference also it is eligible for GC)
If an Object eligible for Gc and when ever JVM runs garbage collector then only that objects will destroyed.
we can also request to JVM to run GC in the followin ways
the behaviour of garbage collector vendor dependent hence we cant expect exactly when JVM executes GC, in wich order GC destroys the objects, is Gc destroy all eligible objects... etc
there are so many things remaining about garbage collection, digg the things..