Java -Xms:初始堆大小或最小堆大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1951347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
-Xms : Initial heap size or minimum heap size?
提问by Suraj Chandran
-Xms is to specify initial heap size or minimum heap size? I see lot of places with lot of different answers. Some like second answer here, say that it is for initial heap and some like heresay that its minimum heap size. Or is it that the minimum size itself is the initial size?
-Xms 是指定初始堆大小还是最小堆大小?我看到很多地方有很多不同的答案。有人喜欢这里的第二个答案,说它用于初始堆,有人喜欢这里说它的最小堆大小。还是最小尺寸本身就是初始尺寸?
采纳答案by Thomas Jung
The initial heap size is the minimum heap size. It won't get smaller than the initial heap size.
初始堆大小是最小堆大小。它不会小于初始堆大小。
From Tuning Garbage Collection with the 5.0 Java[tm] Virtual Machine:
By default, the virtual machine grows or shrinks the heap at each collection to try to keep the proportion of free space to live objects at each collection within a specific range. This target range is set as a percentage by the parameters -XX:MinHeapFreeRatio= and -XX:MaxHeapFreeRatio=, and the total size is bounded below by -Xms and above by -Xmx .
默认情况下,虚拟机在每个集合处增加或缩小堆,以尝试将每个集合处的可用空间与活动对象的比例保持在特定范围内。此目标范围由参数 -XX:MinHeapFreeRatio= 和 -XX:MaxHeapFreeRatio= 设置为百分比,并且总大小低于 -Xms ,高于 -Xmx 。
回答by TofuBeer
From running java -X:
从运行 java -X:
-Xms<size> set initial Java heap size
-Xmx<size> set maximum Java heap size
-Xss<size> set java thread stack size
Note that -X options are not guaranteed to exist on all VMs or behave the same on all VMs. For example -Xms could format your hard drive depending on the VM (it would not - but strictly speaking it could :-) (typing java by itself gives the help with this line: "-X print help on non-standard options").
请注意,不保证 -X 选项存在于所有 VM 上或在所有 VM 上的行为都相同。例如 -Xms 可以根据 VM 格式化您的硬盘驱动器(它不会 - 但严格来说它可以:-)(单独输入 java 会提供这一行的帮助:“-X 打印非标准选项的帮助”) .