Public
Authored by Matija Obreza

Java memory and Docker

From JDK 8u131+ and JDK 9, there’s an experimental VM option that allows the JVM ergonomics to read the memory values from CGgroups. To enable it on, you must explicit set the parameters -XX:+UnlockExperimentalVMOptions and -XX:+UseCGroupMemoryLimitForHeap on the JVM.

Symptoms

The -Xmx flag in JVM before 8u131 still resulted in Java trying to allocate more memory than allowed by docker because it detected all memory available instead of the docker limits. Docker in turn killed the container.

No combination of flags allowed us to set limits. Migrating to the newer jetty image with the updated JRE 8 finally addressed this issue.

Edited
203 Bytes
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment