In short. A container memory limit covers everything the JVM uses, and the heap is only part of it. Metaspace, thread stacks, the code cache and direct buffers live outside the heap, so a pod with -Xmx close to its limit is killed while the heap still has room. Size the limit as heap plus non-heap, check which GC and how many CPUs the JVM really sees, and add a startup probe. jvm-fit does that arithmetic from the manifest before you deploy.
The pod restarts with exit code 137. The dashboard shows the heap at 50 or 60 percent. Nothing in the application log, because the kernel killed the process and the JVM never got to write an OutOfMemoryError . This is one of the most common ways Java breaks on Kubernetes, and the cause is almost always visible in the manifest.
Why is the pod killed when the heap isn't full?
Because the limit is on the container, and the heap is one of several things in it. The JVM also needs memory for:
Metaspace : class metadata.…