I run a Java (21) application in my k8s cluster.
I defined the -Xms
and -Xmx
values to be 780 mib. If I set a lower value to -Xmx
the application crashes with out of memory error.
I set the request and the limit of the container to be 600 mib.
I expected the app to be terminated with an out of memory error, but the container is running.
In addition, by using the kubectl top
I see that the container is using 545 mib, and indeed when I set a lower limit the app is crashed with OOM.
How the -Xms
and -Xmx
are higher than the limit and the container is running?
I see that defining a lower -Xmx
value leads to OOM, so I assume the JVM is actually using it, but when I set the limit to this value (lower than -Xmx
) the container runs. How is it possible?
Ben Izhak is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.