Your Java service runs in a Kubernetes pod with a memory limit, and you have to decide how big the heap may grow. There are two ways to say it: a fixed -Xmx , or a percentage with -XX:MaxRAMPercentage . This guide explains how MaxRAMPercentage vs Xmx behaves inside a container, which one to pick, and how to choose the number so the pod is not OOMKilled. It is written for engineers who deploy JVM services on Kubernetes and have to defend the setting in a review.
“ Shipping container stacks – Port of Rotterdam – 2014 – 2 ” by AgainErick, CC BY-SA 4.0
What the JVM does when you set nothing
Since container support is on by default, the JVM reads the cgroup memory limit instead of the node’s RAM.…