OpenJDK 1.8.0_242,MaxRAMFraction设置未反映 [英] OpenJDK 1.8.0_242, MaxRAMFraction setting not reflecting

查看:1217
本文介绍了OpenJDK 1.8.0_242,MaxRAMFraction设置未反映的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在alpine-OpenJDK映像中运行Springboot应用程序,并且遇到内存不足的问题。最大堆容量上限为256MB。我尝试将MaxRAMFraction设置更新为1,但没有看到它反映在Java_process中。我可以选择将容器内存限制增加到3000m,但希望使用MaxRamfraction = 1的Cgroup内存。有什么想法吗?

I am running a Springboot application in the alpine-OpenJDK image and facing OutOfMemory issues. Max heap is being capped at 256MB. I tried updating the MaxRAMFraction setting to 1 but did not see it getting reflected in the Java_process. I have an option to increase the container memory limit to 3000m but would prefer to use Cgroup memory with MaxRamfraction=1. Any thoughts?

Java-Version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (IcedTea 3.15.0) (Alpine 8.242.08-r0)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

bash-5.0$ java -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|MaxRAMFraction"
    uintx DefaultMaxRAMFraction                     = 4                                   {product}
    uintx MaxHeapSize                              := 262144000                           {product}
    uintx MaxRAMFraction                            = 4                                   {product}
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (IcedTea 3.15.0) (Alpine 8.242.08-r0)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)

Container Resource limits
 ports:
        - containerPort: 8080
          name: 8080tcp02
          protocol: TCP
        resources:
          limits:
            cpu: 350m
            memory: 1000Mi
          requests:
            cpu: 50m
            memory: 1000Mi
        securityContext:
          capabilities: {}

容器JAVA_OPTS屏幕截图

推荐答案


最大堆容量限制为256MB

Max heap is being capped at 256MB.

您是说通过docker中的 -m 吗?如果是这样,这不是您指定的Java堆,而是总内存。

You mean via -m in docker? If such, this is not the java heap you are specifying, but the total memory.


我尝试更新MaxRAMFraction设置为1

I tried updating the MaxRAMFraction setting to 1

MaxRAMFraction 已弃用且未使用,算了

MaxRAMFraction is deprecated and un-used, forget about it.


UseCGroupMemoryLimitForHeap

UseCGroupMemoryLimitForHeap

是不推荐使用,将被删除。使用也移植到java-8的 UseContainerSupport

is deprecated and will be removed. Use UseContainerSupport that was ported to java-8 also.


MaxRAM = 2g

MaxRAM=2g

知道这实际上是做什么的吗?它设置了JVM应该认为您拥有的物理 RAM的值。

Do you know what this actually does? It sets the value for the "physical" RAM that the JVM is supposed to think you have.

我假设您没有设置 -Xms -Xmx 是故意在这里吗?既然您不知道该容器将有多少内存?如果是这样,我们是同一双鞋。我们要做知道我们要得到的最小值是 1g ,但是我不知道最大值,因此我不想设置 -Xms -Xmx 明确。

I assume that you did not set -Xms and -Xmx on purpose here? Since you do not know how much memory the container will have? If such, we are in the same shoes. We do know that the min we are going to get is 1g, but I have no idea of the max, as such I prefer not to set -Xms and -Xmx explicitly.

相反,我们这样做:

-XX:InitialRAMPercentage=70
-XX:MaxRAMPercentage=70
-XX:+UseContainerSupport
-XX:InitialHeapSize=0

就是这样。

InitialRAMPercentage 用于计算初始堆大小,但仅当 InitialHeapSize / Xms 丢失。 MaxRAMPercentage 用于计算最大堆。不要忘记Java进程需要的不仅仅是 heap ,它还需要本机结构。这就是为什么 70 (%)。

InitialRAMPercentage is used to calculate the initial heap size, BUT only when InitialHeapSize/Xms are missing. MaxRAMPercentage is used to calculate the maximum heap. Do not forget that a java process needs more than just heap, it needs native structures also; that is why that 70 (%).

这篇关于OpenJDK 1.8.0_242,MaxRAMFraction设置未反映的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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