将Xms和Xmx设置为相同的值有什么好处? [英] Is there any advantage in setting Xms and Xmx to the same value?

查看:1038
本文介绍了将Xms和Xmx设置为相同的值有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,我设置-Xms512m-Xmx1g,以便在JVM启动时分配512MB,并根据需要将堆逐渐增加到1GB.但是在专用服务器实例中,我看到这些值设置为相同的1g.将两者设置为相同的值有什么好处吗?

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 set to same say 1g in a dedicated server instance. Is there any advantage for the having both set to the same value?

推荐答案

好几件事.

  1. 程序将以-Xms值开头,如果该值较小,则最终将迫使GC发生频率更高
  2. 一旦程序到达-Xms堆,jvm请求操作系统提供更多内存,并最终获取-Xmx,这需要花费更多时间导致性能问题,因此您最好在开始时将其设置为-Xmx,从而避免jvm请求额外的内存. /li>
  1. Program will start with -Xms value and if the value is lesser it will eventually force GC to occur more frequently
  2. Once the program reaches -Xms heap, jvm request OS for additional memory and eventually grabs -Xmx that requires additional time leading to performance issue, you might as well set it to that at the beginning avoiding jvm to request additional memory.

这里的答案非常好- https://developer.jboss.org/thread /149559?_sscc = t

这篇关于将Xms和Xmx设置为相同的值有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆