4

I have found a legacy software that we're using that has its launch properties malformed, so it receives these two unequal xmx as a properties:

java -jar myapp.jar -Xmx128m -Xmx512m 

I do not have access to the launcher source code(not being able to modify it), so I ask, what is the impact of the duplication of these parameters? Can I leave this in this way, or should I worry? Which one will be applied?

The JVM used is JRE 6 update 18

Rich
  • 5,603
  • 9
  • 39
  • 61
kurast
  • 1,660
  • 3
  • 17
  • 38

2 Answers2

6

In general, it's usually the latter option that gets used if a tool doesn't reject a duplicate, but you can't count on that unless the tool documents it.

Your best bet is to see what happens with your specific JVM, via Runtime's 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);
    }
}

On my JVM (Sun/Oracle 1.6.0_26-b03 under Linux), the latter 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
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
1

My understanding it that it will use the last setting.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130