Althrough java provides automatic garbage collection sometimes you will want to know how large the object is and how much of it is left .Free memory using programatically import java.lang;
and Runtime r=Runtime.getRuntime();
to obtain values of memory using mem1=r.freeMemory();
to free memory call the r.gc();
method and the call freeMemory()