java -XX:MinHeapFreeRatio 和 -XX:MaxHeapFreeRatio 的目的是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16058250/
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
what is the purpose of -XX:MinHeapFreeRatio and -XX:MaxHeapFreeRatio
提问by Praveen Kumar
Kindly tell me the purpose of those options. After googling I think: MinHeapFreeRatio tells "specified minimum percentage of space will be ensured to be free in heap memory after a GC" and MaxHeapFreeRatio tells "no more than specified percentage of space will be free in heap memory after a GC" [if there is excess free memory than the specified percentage, those memory will be returned to OS]
请告诉我这些选项的目的。谷歌搜索后我认为: MinHeapFreeRatio 告诉“在 GC 后将确保堆内存中指定的最小空间百分比是可用的”,而 MaxHeapFreeRatio 告诉“在 GC 后堆内存中将不超过指定百分比的可用空间”[如果有超出指定百分比的可用内存,这些内存将返回给操作系统]
When i tried these options with 10 as value for both, even where there is more than 80 percentage of free heap memory, it was not released back to OS.
当我尝试使用 10 作为两个值的这些选项时,即使有超过 80% 的空闲堆内存,它也不会释放回操作系统。
Details:
细节:
Java HotSpot(TM) 64-Bit Server VM (1.5.0_15-b04, mixed mode) ParallelGC (otherwise known as throughput collector which is the default collector in server class VM) i specified -Xms50M and -Xmx1000M as jvm arguments OS: windows 7 professional (8 GB memory 64 bit OS)
Java HotSpot(TM) 64 位服务器 VM(1.5.0_15-b04,混合模式)ParallelGC(也称为吞吐量收集器,它是服务器类 VM 中的默认收集器)我指定 -Xms50M 和 -Xmx1000M 作为 jvm 参数 OS:windows 7 专业版(8 GB 内存 64 位操作系统)
Note: i just tried with SerialGC too, those min and max heap free ratio options were ignored.
注意:我也刚刚尝试过 SerialGC,忽略了那些最小和最大堆空闲比率选项。
回答by Peter Lawrey
Java very rarelyreleases memory back to the OS.
Java很少将内存释放回操作系统。
Generally speaking, applications use more memory over time rather than less. Are you sure you memory is so limited that you need this? Are you sure you are checking the resident memory not the virtual memory size which will be about 1.2 GB in your case all the time.
一般来说,随着时间的推移,应用程序使用更多的内存而不是更少。你确定你的记忆力如此有限以至于你需要这个吗?您确定要检查的是常驻内存而不是虚拟内存大小,在您的情况下,虚拟内存大小始终约为 1.2 GB。