//The garbage collector deallocates memory of unreferenced objects
//example
cl obj1=new cl();
System.gc();
//the GC does nothing here since obj 1 is still referenced
cl=null;
System.gc();
//the GC deallocates the memory previously allocated for obj1 since it's no longer referenced //This makes the life of a programmer (for example when freeing an array of objects : a single command instead of a loop
|