Java heap size defaults when running with CGroups in Linux.

David Holmes david.holmes at oracle.com
Thu Dec 1 00:40:38 UTC 2016


Hi Christine,

On 1/12/2016 7:59 AM, Christine Flood wrote:
>
> 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.  http://matthewkwilliams.com/index.php/2016/03/17/docker-cgroups-memory-constraints-and-java-cautionary-tale/
>
> 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:  http://cr.openjdk.java.net/~andrew/rh1390708/webrev.01/

We are aware of the problem with Docker - please see:

https://bugs.openjdk.java.net/browse/JDK-8146115

It has been unclear exactly how the Cgroup limits should affect the VM's 
interpretation of what memory is available. Is it as simple as 
pretending memory.limit_in_bytes represents physical memory? I don't 
know for sure - what about the other limits, how might they impact the VM?

There is also the issue that the cgroup file system needs to be loaded 
to enable this to be done - something which has often been lacking in 
Docker environments.

I also agree with Mikael - if we are running in a constrained 
environment like Cgroups then wouldn't we want to do this 
unconditionally? Or at least the default would be to do it?

Thanks,
David

>
> Christine
>
>
>
>
>
>
>


More information about the hotspot-dev mailing list