In general, this is usually the last option that is used if the tool does not reject the duplicate, but you cannot count on it if the tool does not document it.
Itโs best to see what happens with your particular JVM through Runtime
totalMemory
and maxMemory
:
public class HeapSize { public static final void main(String[] args) { Runtime rt = Runtime.getRuntime(); System.out.println("Total currently: " + rt.totalMemory()); System.out.println("Max: " + rt.maxMemory()); System.exit(0); } }
In my JVM (Sun / Oracle 1.6.0_26-b03 for Linux), the last option takes effect:
$ java -Xmx16m HeapSize
Total currently: 16121856
Max: 16121856
$ java -Xmx32m HeapSize
Total currently: 32178176
Max: 32178176
$ java -Xmx16m -Xmx32m HeapSize
Total currently: 32178176
Max: 32178176
$ java -Xmx16m -Xmx32m -Xmx128m HeapSize
Total currently: 59113472
Max: 119341056
source share