Java GC runs cause increase of mem usage on OS

8/2/2018

The last days I have seen some behaviour which crashes some assumption of me. Maybe someone can give me an explanation of the following

The facts

  • We are running Java Applications in Docker Containers in K8s in GCP
  • Our base image is openjdk:8u171-jre-slim-stretch
  • We engaged the flags -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap => so resource limits should be obtained from the container and not from the hosts => IMO that works
  • We engaged XX:MaxRAMFraction=2 so we get about the half of the containers memory limit for the heap => IMO that works
  • There is no -Xmx setting for the JVM
  • The only way to influence the JVMs memory is via Kubernetes resource limits => which is exactly what we want

The thing I do not get

When GC kicks in (Scavenge or G1) there is an increase in container memory usage, but not in the jvm memory usage. Why does the GC consume memory from the container? OK, it copies stuff eg from old gen to young gen so I understand that for a short time more memory is used. But I have expected that this would be taken from the JVM process and not from some kernel process.

-- Hubert Ströbitzer
docker
garbage-collection
java
kubernetes

0 Answers