According to the documentation the VM requires that -Xmx (MaxHeapSize) is at least 2m:
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
But there is no check in the VM to verify this. On the other hand we silently increase the size to 2m if anything less is specified:
$ java -Xmx1m -XX:+PrintFlagsFinal -version | grep MaxHeapSize
uintx MaxHeapSize := 2097152 {product}
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b35)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b35, mixed mode)
If you happen to go below 1m we fail the minimum heap size test (-Xms):
$ java -Xmx1023k -version
Error occurred during initialization of VM
Too small initial heap
The reason the VM does not start with 1023K is actually not that we check the maximum heap size (Xmx) but that we check the initial heap size (Xms). Xms must be larger than 1m otherwise the VM does not start.
It would be better to have an explicit check that -Xmx is > 2m and otherwise not start the VM.
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
But there is no check in the VM to verify this. On the other hand we silently increase the size to 2m if anything less is specified:
$ java -Xmx1m -XX:+PrintFlagsFinal -version | grep MaxHeapSize
uintx MaxHeapSize := 2097152 {product}
java version "1.9.0-ea"
Java(TM) SE Runtime Environment (build 1.9.0-ea-b35)
Java HotSpot(TM) 64-Bit Server VM (build 1.9.0-ea-b35, mixed mode)
If you happen to go below 1m we fail the minimum heap size test (-Xms):
$ java -Xmx1023k -version
Error occurred during initialization of VM
Too small initial heap
The reason the VM does not start with 1023K is actually not that we check the maximum heap size (Xmx) but that we check the initial heap size (Xms). Xms must be larger than 1m otherwise the VM does not start.
It would be better to have an explicit check that -Xmx is > 2m and otherwise not start the VM.
- blocks
-
JDK-8067776 [NEWTEST] Test that VM doesn't start if -Xmx (MaxHeapSize) is less than 2m
-
- Closed
-
- duplicates
-
JDK-8067776 [NEWTEST] Test that VM doesn't start if -Xmx (MaxHeapSize) is less than 2m
-
- Closed
-