Skip to content
Ameen Abozaid
Planned lessonMID-002-L05

The JVM inside a container

  • Lesson 5 of 7
  • Mid-level
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 -Xmx that 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

text
container limit 1 GiB -> MaxRAMPercentage=70 -> heap ~700 MiB, ~300 MiB left for non-heap

Check 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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.