JVM Duplication Options

I found outdated software that we use that has its malformed launch properties, so it gets these two unequal xmx as properties:

java -jar myapp.jar -Xmx128m -Xmx512m 

I donโ€™t have access to the initial launch code (not being able to modify it), so I ask, what is the effect of duplicating these parameters? Can I leave it this way, or should I worry? Which one will be applied?

JVM uses JRE 6 update 18

+4
source share
2 answers

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 
+6
source

I understand that he will use the last setting.

+1
source

Source: https://habr.com/ru/post/1383881/


All Articles