As always, check the local specific implementation of the JVM, but here is a quick way to check from the command line without the need for code.
> java -version; java -Xmx1G -XX:+PrintFlagsFinal -Xmx2G 2>/dev/null | grep MaxHeapSize java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode) uintx MaxHeapSize := 2147483648 {product}
So, in this case, you will see that the second instance of the argument (2G) takes precedence (at least in version 1.8), and that was my experience with most other modern versions.
David Hergert Nov 04 2018-11-14T00: 00Z
source share