I have written simple code in java as follows
public static void main(String[] args) {
    String st ="Java";
    StringBuffer sb = new StringBuffer(st); 
    long startTime = System.currentTimeMillis();
    Runtime r = Runtime.getRuntime();
    long startm = r.freeMemory();
    System.out.println("Before running program free memory is: "+startm);
    for(int i=0; i<10000; i++)
        st+="is";
    long endm = r.freeMemory();
    System.out.println("After program free memory is: "+endm);
}   
However the problem is when I run the program, free memory is increasing after loop is finished but it should be less than in beginning of the program. My output is as follows:
Before running program free memory is: 61089768
After program free memory is: 123747064
Please tell me why is that?
 
     
    