The JVM inside a container
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
size heap and container limits so they fit together.
Planned topics
- Modern JVMs read cgroup limits; the default max heap is a fraction of container memory.
- Set it explicitly with
-XX:MaxRAMPercentage(for example 60-75), not a fixed-Xmxthat ignores the limit. - Heap is only part of process memory: metaspace, thread stacks, code cache, direct buffers also count.
- If total exceeds the limit, the container is OOM-killed (exit 137), with no Java exception.
- Set CPU limits knowing they change the GC and compiler thread counts.
Draft outline details
Demonstration
container limit 1 GiB -> MaxRAMPercentage=70 -> heap ~700 MiB, ~300 MiB left for non-heapCheck your understanding
Why can a pod be killed while heap usage looks fine?
Show answer
Non-heap memory pushed the process over the container limit.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.