T
Thomas Kellerer
Hello,
according to the JavaDocs Runtime.freeMemory() should report the size of the
free memory, but is this not affected by the -Xmx parameter. When I run the
following program:
public class Memory
{
public static void main(String[] args)
{
System.out.println(Runtime.getRuntime().freeMemory());
}
}
it prints the same amount regardless of the -Xmx parameter value:
java Memory --> 1850616
java -Xmx512m Memory --> 1850616
It seems always to report something around 2-4 MB (either JDK 1.5 or JDK 1.6)
When I use maxMemory() - totalMemory() this does seem to reflect the current
heap size a lot closer.
What am I missing here?
I would like to implement a threshold where certain information is no longer
stored internally when the memory gets low. But with freeMemory() this does not
seem to be a viable solution.
Thanks in advance
Thomas
according to the JavaDocs Runtime.freeMemory() should report the size of the
free memory, but is this not affected by the -Xmx parameter. When I run the
following program:
public class Memory
{
public static void main(String[] args)
{
System.out.println(Runtime.getRuntime().freeMemory());
}
}
it prints the same amount regardless of the -Xmx parameter value:
java Memory --> 1850616
java -Xmx512m Memory --> 1850616
It seems always to report something around 2-4 MB (either JDK 1.5 or JDK 1.6)
When I use maxMemory() - totalMemory() this does seem to reflect the current
heap size a lot closer.
What am I missing here?
I would like to implement a threshold where certain information is no longer
stored internally when the memory gets low. But with freeMemory() this does not
seem to be a viable solution.
Thanks in advance
Thomas