OpenJDK 1.8.0_242, MaxRAMFraction setting not reflecting OpenJDK 1.8.0_242, MaxRAMFraction setting not reflecting kubernetes kubernetes

OpenJDK 1.8.0_242, MaxRAMFraction setting not reflecting


Max heap is being capped at 256MB.

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

I tried updating the MaxRAMFraction setting to 1

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

UseCGroupMemoryLimitForHeap

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

MaxRAM=2g

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

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.

Instead, we do:

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

And that's it. What this does?

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 (%).