Why I am getting a variable output for the following code :
Runtime rt = Runtime.getRuntime();
long x,y;
x = rt.freeMemory();
char z[] = new char[Index];
y = rt.freeMemory();
System.out.println("Difference = " + (x-y))
Output is = Zero for lesser Value of Index(<10000) but for values >=100000 value is 200016.For every Zero addition it becomes 2000016.
How is it possible. [edited]My aim is to find the size of the Data Object(used in the code- like here I have used Char z[] of Index Size) in the memory.