Cgroup Awareness in Java
If you limit your container to 1GB of RAM but don't configure your JVM correctly, the JVM will try to allocate as much as it sees on the host machine. The Linux kernel will then kill your container with an signal.
1. JVM Container Support
- -XX:+UseContainerSupport: Enabled by default since Java 10. It forces the JVM to read the memory limit files.
- -XX:MaxRAMPercentage: Don't set to a fixed value. Use to dynamically let the JVM take 75% of the container's RAM.
2. Monitoring
Always check inside your container to see exactly what the JVM sees.
