Java heap size defaults when running with CGroups in Linux.
david.holmes at oracle.com
Fri Dec 2 01:57:00 UTC 2016
On 2/12/2016 12:50 AM, Christine Flood wrote:
> Unfortunately, if you aren't actually inside a cgroup, /sys/fs/cgroup/memory/memory.limit_in_bytes still exists and contains an apparently bogus value. I've got a question in to the docker folks to find out why.
Is that the "unlimited" value that you get even if running in a cgroup
but without setting a memory limit?
As I wrote in the bug report when initially investigating this there
seem to be a lot of issues with even knowing what to read:
"/sys/fs/cgroup/ is the recommended location for cgroup hierarchies, but
it is not a standard. If a tool or library is trying to read from it,
and be portable across multiple container implementations, it would need
to discover the location first by parsing /proc/self/cgroup and
/proc/self/mountinfo. Further, /sys/fs/cgroup is just an umbrella for
all cgroup hierarchies, there is no recommendation or standard for my
own cgroup location."
> In the short term, providing a runtime flag gives us a way to protect customers that are running inside a container and not change the current behavior for everyone else.
Ok - at best this enhancement would be an experimental flag that users
would have to opt in to.
But the enhancement door is barely still open for JDK 9.
> ----- Original Message -----
>> From: "Mikael Vidstedt" <mikael.vidstedt at oracle.com>
>> To: "Christine Flood" <chf at redhat.com>
>> Cc: hotspot-dev at openjdk.java.net
>> Sent: Wednesday, November 30, 2016 5:53:41 PM
>> Subject: Re: Java heap size defaults when running with CGroups in Linux.
>> Out of curiosity, why wouldn’t this be the default behavior? That is, in
>> which cases is it not a good idea to use the cgroup information when sizing
>> the JVM?
>>> On Nov 30, 2016, at 1:59 PM, Christine Flood <chf at redhat.com> 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.
>>> 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/
More information about the hotspot-dev