A DESCRIPTION OF THE REQUEST :
Hello,
One of my JVM is setting the max heap size (-Xmx1024m) to 1 GB. When the memory was peak, I saw:
Max = 910 MB (This value is from runtime.maxMemory())
Committed = 1002 MB (This value is from runtime.totalMemory())
Used = 978 MB (This value is from runtime.totalMemory() - runtime.freeMemory())
I saw the memory usage percent around 107%. I also confuse why the max heap size is not equal to the one I set (1024 MB).
I'm using Oracle JDK 1.7.0_40.
Regards,
Pornpan
JUSTIFICATION :
When I calculated the memory usage percentage should not over 100%.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
runtime.maxMemory() = the value of -Xmx param
ACTUAL -
$ /usr/java/jdk1.7.0_40/bin/java -Xmx1024m TestMemory
##### Heap utilization statistics [MB] #####
Used Memory:3
Free Memory:659
Total Memory:662
Max Memory:910
---------- BEGIN SOURCE ----------
public class TestMemory {
public static void main(String [] args) {
int mb = 1024*1024;
//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
System.out.println("##### Heap utilization statistics [MB] #####");
//Print used memory
System.out.println("Used Memory:"
+ (runtime.totalMemory() - runtime.freeMemory()) / mb);
//Print free memory
System.out.println("Free Memory:"
+ runtime.freeMemory() / mb);
//Print total available memory
System.out.println("Total Memory:" + runtime.totalMemory() / mb);
//Print Maximum available memory
System.out.println("Max Memory:" + runtime.maxMemory() / mb);
}
}
---------- END SOURCE ----------
Hello,
One of my JVM is setting the max heap size (-Xmx1024m) to 1 GB. When the memory was peak, I saw:
Max = 910 MB (This value is from runtime.maxMemory())
Committed = 1002 MB (This value is from runtime.totalMemory())
Used = 978 MB (This value is from runtime.totalMemory() - runtime.freeMemory())
I saw the memory usage percent around 107%. I also confuse why the max heap size is not equal to the one I set (1024 MB).
I'm using Oracle JDK 1.7.0_40.
Regards,
Pornpan
JUSTIFICATION :
When I calculated the memory usage percentage should not over 100%.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
runtime.maxMemory() = the value of -Xmx param
ACTUAL -
$ /usr/java/jdk1.7.0_40/bin/java -Xmx1024m TestMemory
##### Heap utilization statistics [MB] #####
Used Memory:3
Free Memory:659
Total Memory:662
Max Memory:910
---------- BEGIN SOURCE ----------
public class TestMemory {
public static void main(String [] args) {
int mb = 1024*1024;
//Getting the runtime reference from system
Runtime runtime = Runtime.getRuntime();
System.out.println("##### Heap utilization statistics [MB] #####");
//Print used memory
System.out.println("Used Memory:"
+ (runtime.totalMemory() - runtime.freeMemory()) / mb);
//Print free memory
System.out.println("Free Memory:"
+ runtime.freeMemory() / mb);
//Print total available memory
System.out.println("Total Memory:" + runtime.totalMemory() / mb);
//Print Maximum available memory
System.out.println("Max Memory:" + runtime.maxMemory() / mb);
}
}
---------- END SOURCE ----------