澄清新的JVM内存参数InitialRAMPercentage和MinRAMPercentage的含义

Clarification of meaning new JVM memory parameters InitialRAMPercentage and MinRAMPercentage(澄清新的JVM内存参数InitialRAMPercentage和MinRAMPercentage的含义)

本文介绍了澄清新的JVM内存参数InitialRAMPercentage和MinRAMPercentage的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

参考:https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8186315

我真的很难找出 MinRAMPercentage 的作用,尤其是与 InitialRAMPercentage 相比.

I'm really struggling to find out what MinRAMPercentage does, especially compared to InitialRAMPercentage.

我假设 InitialRAMPercentage 设置启动时的堆数量,MinRAMPercentage 和 MaxRAMPercentage 设置允许 JVM 收缩/增长的堆的上下限.

I assumed that InitialRAMPercentage sets the amount of heap at startup, that MinRAMPercentage and MaxRAMPercentage set the bottom and top limit of heap that the JVM is allowed to shrink/grow to.

显然情况并非如此.当我像这样启动 JVM(使用 UseContainerSupport,具有这些新的内存设置参数)时:

Apparently that is not the case. When I start a JVM (with UseContainerSupport, having these new memory setting parameters) like so:

java -XX:+UseContainerSupport -XX:InitialRAMPercentage=40.0 -XX:MinRAMPercentage=20.0 -XX:MaxRAMPercentage=80.0 -XX:+PrintFlagsFinal -version | grep Heap

InitialHeap 和 MaxHeap 已设置,我找不到最小堆大小"值;因此,MinRAMPercentage 似乎从未被使用过.

InitialHeap and MaxHeap get set, there is no "Minimum Heap Size" value that I can find; Consequently, that MinRAMPercentage never seems to get used.

超级困惑,显然,我不是唯一一个;OpenJ9 伙计们似乎也没有完全解析这些选项的意图,因为我已经收集了 here 和 这里.他们似乎选择干脆不实施 MinRAMPercentage afaics.

Super confused, and apparently, I'm not the only one; the OpenJ9 dudes seem to also not fully parse the intent of these options, as I've gathered here and here. They seem to have opted to simply not implement MinRAMPercentage afaics.

那么:设置 MinRAMPercentage 的真正预期用途和效果是什么?

So: What is the real intended usage and effect of setting MinRAMPercentage?

推荐答案

-XX:InitialRAMPercentage用于计算初始堆大小 当InitialHeapSize/-Xms 未设置.

这听起来违反直觉,但是 -XX:MaxRAMPercentage-XX:MinRAMPercentage 都用于计算 最大堆大小 MaxHeapSize/-Xmx 未设置:

It sounds counterintuitive, but both -XX:MaxRAMPercentage and -XX:MinRAMPercentage are used to calculate maximum heap size when MaxHeapSize / -Xmx is not set:

  • 对于物理内存较小的系统,MaxHeapSize 估计为

phys_mem * MinRAMPercentage / 100  (if this value is less than 96M)

  • 否则(非小物理内存)MaxHeapSize估计为

    MAX(phys_mem * MaxRAMPercentage / 100, 96M)
    

  • 确切的公式有点复杂,因为它还考虑了其​​他因素.

    The exact formula is a bit more complicated as it also takes other factors into account.

    注意:计算初始和最大堆大小的算法取决于特定的 JVM 版本.控制堆大小的首选方法是显式设置 XmxXms.

    Note: the algorithm for calculating initial and maximum heap size depends on the particular JVM version. The preferred way to control the heap size is to set Xmx and Xms explicitly.

    另请参阅这个问题.

    这篇关于澄清新的JVM内存参数InitialRAMPercentage和MinRAMPercentage的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

    本文标题为:澄清新的JVM内存参数InitialRAMPercentage和MinRAMPercentage的含义

    基础教程推荐