Author here. Short version: the container limit covers the whole JVM, not just the heap, so -Xmx close to the limit leaves no room for metaspace, thread stacks, code cache and direct buffers.
Three things I measured on Temurin 11, 17 and 21 that are easy to get wrong:
- 2 CPUs with a 1Gi limit still gives SerialGC. G1 also needs about 1792Mi.
- A 256Mi limit gives a 126M heap, not 25%.
- With -XX:-UseContainerSupport the heap is sized from the host's memory.
I wrote a small open-source CLI, jvm-fit, that does this arithmetic from the manifest before deploy: https://github.com/andronaft/jvm-fit. It is a static check, so it complements tools like KRR rather than replacing them. Happy to hear where the model is wrong.
submitted by