Is there any advantage in setting Xms and Xmx to the same value?

后端 未结 5 1403
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-08 21:48

Usually I set -Xms512m and -Xmx1g so that when JVM starts it allocates 512MB and gradually increases heap to 1GB as necessary. But I see these values s

5条回答
  •  深忆病人
    2021-02-08 22:17

    There are some advantages.

    • if you know the size is going to grow to the maximum, e.g. in a benchmark, you may as well start with the size you know you need.
    • you can get better performance giving the program more memory that it might naturally give itself. YMWV

    In general, I would make the Xms a value I am confident it will use, and the double this for head room for future use cases or situations we haven't tested for. i.e. a size we don't expect but it might use.

    In short, the maximum is the point you would rather the program fail than use any more.

提交回复
热议问题