What's the reason to set a minimal Java Heap Size?

北城以北 提交于 2019-12-10 18:32:51

问题


I can set the Java Heap Size minimum and maximum by passing the parameters -Xms and -Xmx, respectively.

I understand that the maximum flag is necessary to limit the space, but what's the reason for setting a minimum initial heap size? If the maximum is big enough, the space will increase? Or do i miss something?


回答1:


Minimun size is set so that the JVM doesn't have to "resize" the heap space if it starts off too small.




回答2:


Java will start with the minimum heap size and will try to avoid enlarging the heap by garbage collecting.

So if the steady-state memory size of your app is larger than the default heap minimum heap size, you may do a lot of pointless GC on the way to that size. Setting the min size to that size will avoid the pointless GC.




回答3:


You can set the minimum heap size if your application needs a certain amount to run. If you set the maximum heap size, the jvm isn't supposed to exceed it.



来源:https://stackoverflow.com/questions/8085949/whats-the-reason-to-set-a-minimal-java-heap-size

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!