Given these two commands
A:
$ java -Xms10G -Xmx10G myjavacode input.txt
B:
$ java -Xms5G -Xmx5G myjavacode input.txt
I have two questions:
- Since command A reserves more memory with its parameters, will A run faster than B?
- How do
-Xmxand-Xmsaffect the running process and the output of my program?
It depends on the GC your java is using. Parallel GCs might work better on larger memory settings – I’m no expert on that though.
In general, if you have larger memory the less frequent it needs to be GC-ed – there is lots of room for garbage. However, when it comes to a GC, the GC has to work on more memory – which in turn might be slower.