Java heap size defaults when running with CGroups in Linux.

Christine Flood chf at
Wed Nov 30 21:59:56 UTC 2016

The problem is that when running the JVM inside of a cgroup, such as docker, the JVM bases it's default heap parameters on the size of the whole machine's memory not on the memory available to the container.  This causes errors as discussed on this blog entry.

Basically the JVM dies in a non-obvious manner.

The solution I propose is to add a parameter -XX:+UseCGroupLimits to the JVM which states that you should look to the CGroup when calculating default heap sizes. 

Webrev is here:


More information about the hotspot-dev mailing list