G1 GC does not validate or correct inconsistencies between -XX:NewSize / -XX:MaxNewSize and -XX:MaxHeapSize / -XX:InitialHeapSize. As a result, it’s possible to specify a NewSize or MaxNewSize larger than the total heap size, and the JVM accepts these settings without warning or correction.
$ java -Xmn20G -XX:+PrintFlagsFinal -version
size_t InitialHeapSize = 8342470656 {product} {ergonomic}
size_t MaxHeapSize = 8342470656 {product} {ergonomic}
size_t MaxNewSize = 21474836480 {product} {command line}
size_t NewSize = 21474836480 {product} {command line}
Here, both NewSize and MaxNewSize exceed the MaxHeapSize.
Cleanup the argument parsing to set the
NewSize/MaxNewSize within the bounds of InitialHeapSize as well as MaxHeapSize
$ java -Xmn20G -XX:+PrintFlagsFinal -version
size_t InitialHeapSize = 8342470656 {product} {ergonomic}
size_t MaxHeapSize = 8342470656 {product} {ergonomic}
size_t MaxNewSize = 21474836480 {product} {command line}
size_t NewSize = 21474836480 {product} {command line}
Here, both NewSize and MaxNewSize exceed the MaxHeapSize.
Cleanup the argument parsing to set the
NewSize/MaxNewSize within the bounds of InitialHeapSize as well as MaxHeapSize