0

I'd like to ask about your opinion about starting up java process with an equal -Xms and -Xmx which, as java's help says are:

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size

In the java VM performance hints/guide there is an advice regarding -Xms:

"Oracle recommends setting the minimum heap size (-Xms) equal to the maximum heap size (-Xmx) to minimize garbage collections."

just for a test, on a system with 64GB of RAM installed, I have started java process with -Xms50g and -Xmx50g

Should I expect "used" value on free output growing up to 50GB? it doesn't seem to be growing up - or this is a long time process?

$ while true;do free|grep ^Mem;sleep 1;done|ts '[%Y-%m-%d %H:%M:%S]'
[2018-12-01 22:03:08] Mem:       65808916     3345712    56556376       14556     5906828    61863688
[2018-12-01 22:03:09] Mem:       65808916     3347912    56554168       14556     5906836    61861484
[2018-12-01 22:03:10] Mem:       65808916     3347776    56554292       14556     5906848    61861608
[2018-12-01 22:03:11] Mem:       65808916     3348008    56554060       14556     5906848    61861376
[2018-12-01 22:03:12] Mem:       65808916     3347780    56554284       14556     5906852    61861600
[2018-12-01 22:03:13] Mem:       65808916     3348112    56553944       14556     5906860    61861260
[2018-12-01 22:03:14] Mem:       65808916     3347976    56554076       14556     5906864    61861392
[2018-12-01 22:03:15] Mem:       65808916     3347636    56554416       14556     5906864    61861736

what is a benefit/disadvantage of having -Xms/-Xmx set to such huge value?

1 Answer 1

0

When the process really needs that amount, it's faster to reserve it immediately, rather than running against the limit, trying a GC, increasing the heap, again and again.

6
  • how could I check that the 50g in my example is really reserved? the java process with -Xms50g -Xmx50g is running since yesterday and "free -g" command shows that only 3GB is used and 53GB is free.
    – Chris
    Commented Dec 2, 2018 at 10:46
  • What exact version of Java are you running? Check with jmap or other tool if the process accepted your options. Commented Dec 2, 2018 at 20:23
  • java -version returns: java version "1.8.0_92" Java(TM) SE Runtime Environment (build 1.8.0_92-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
    – Chris
    Commented Dec 2, 2018 at 20:35
  • Don't forget java needs more than only the heap. 53G may be too much. No messages when you start the jvm? Commented Dec 2, 2018 at 20:51
  • I think it is a feature that Xms does not reserve configured amount of RAM immediately, I can only observe RAM usage is growing up, now it is about 14GB already of the 50 configured. yes, there are no mesages or warnings when tomcat starts jvm with JAVA_OPTS='-Xms50g -Xmx50g ... (in setenv.sh). The proces is fine and seen running on ps -ef output.
    – Chris
    Commented Dec 3, 2018 at 15:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .