If I deleberately use the statement System.gc()?What will happen to the objects which are not referenced ? Example : Vector objVct = new Vector(); objVct.addElement("Java"); objVct = null; System.gc(); What will happen to vector object(objVct)? At what point of time the Garbage Collector collects this object ?
Hi Oliver, Fundamental of Garbage collection is U can't Force Garbage Collection in Java. Here after putting ur Object Rference to Null, and by calling System.gc() ur trying to tell jvm tht u want this object to be Garbage Collected means u want to Delete this Object from Memory Location. This will be done by a Garbage Collector Daemon Thread but u cannot Give any Guarranty when this will happen. Still if u have some doubt pls tell me . thanks Anurag