hi all,
public class GarbageCollector{
public static void main(
String args[]){
Runtime runtime = Runtime.getInstance();
String s ;
System.out.println(runtime.totalMemory());
System.out.println(runtime.freeMemory());
for(int i=0;i<1000;i++)
s = new String("");
System.out.println(runtime.freeMemory());
runtime.gc();
System.out.println(runtime.freeMemory());
}
}
the above code prints:
2025678
1789000
1749899
1898122
Now when i run this program again, the first print statement for the free memory should give me 1898122 bytes , instead i get 1789000 as the output
i would like to know the reason behind this
thanks
annapurna