JVM堆参数 [英] JVM heap parameters

查看:118
本文介绍了JVM堆参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了有关该主题和大量谷歌搜索的问题后,我仍然无法清楚地了解 -Xms 选项



<我的问题是: java -Xms = 512m -Xmx = 512m java -Xms = 64m -Xmx = 512m之间有什么区别



现在我有以下答案:



唯一的区别在于应用程序运行期间将运行的垃圾收集数和内存分配数。我是对的吗?



以下是我的答案理由:



设置 -Xms 选项 512m 不会导致我的应用程序使用真正的 512M 物理启动后的内存。我想这与现代操作系统虚拟内存管理和延迟页面分配有关。 (我注意到将 -Xms 设置为 512M 64M 不会改变由Linux上的top或Windows上的任务管理器报告的所有初始使用内存。



有人可以帮助我理解这对 Xms 选项或指向我可以帮助我理解的链接?



提前致谢



Manu

解决方案

总结链接后找到的信息:
JVM分配-Xms指定的数量,但OS通常不会在需要之前分配实际页面。因此,JVM按照Xms的指定分配虚拟内存,但只根据需要分配物理内存。



您可以通过Sysinternals使用Process Explorer代替Windows上的任务管理器来查看。



所以使用-Xms64M和-Xms512M之间存在真正的区别。
但我认为最重要的区别是你已经指出的那个:如果你真的需要512MB而垃圾收集器将更频繁地运行,但只开始使用64MB。


After reading already asked question on the subject and a lot of googling I am still not able to have a clear view of -Xms option

My question is: what's the difference between java -Xms=512m -Xmx=512m and java -Xms=64m -Xmx=512m?

For now I have the following answer:

The only difference is in the number of garbage collections that will be run during my application's run and the number of memory allocations. Am I right ?

Here are my reasons for this answer:

Setting the -Xms option to 512m doesn't result in my application using really 512M of physical memory after startup. I guess this is related to modern OS virtual memory management and lazy pages allocations. (I noticed that setting -Xms to 512M or to 64M doesn't change at all the initial used memory reported either by top on Linux or by the task manager on windows)

Can someone help me to understand the impact of this Xms option or point me to links that will help me to understand it?

Thanks in advance

Manu

解决方案

To summarize the information found after the link: The JVM allocates the amount specified by -Xms but the OS usually does not allocate real pages until they are needed. So the JVM allocates virtual memory as specified by Xms but only allocates physical memory as is needed.

You can see this by using Process Explorer by Sysinternals instead of task manager on windows.

So there is a real difference between using -Xms64M and -Xms512M. But I think the most important difference is the one you already pointed out: the garbage collector will run more often if you really need the 512MB but only started with 64MB.

这篇关于JVM堆参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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