0

I read similar questions "what-does-usecontainersupport-vm-parameter-do", but the same parameters do not take effect under my system

Why the jvm parameter UseContainerSupport does not work

  • my system:
➜  ~ screenfetch 

 ██████████████████  ████████     xxxx@manjaro-xps
 ██████████████████  ████████     OS: Manjaro 21.1.0 Pahvo
 ██████████████████  ████████     Kernel: x86_64 Linux 5.13.1-3-MANJARO
 ██████████████████  ████████     Uptime: 2h 22m
 ████████            ████████     Packages: 1365
 ████████  ████████  ████████     Shell: zsh 5.8
 ████████  ████████  ████████     Resolution: 2560x1600
 ████████  ████████  ████████     DE: KDE 5.84.0 / Plasma 5.22.3
 ████████  ████████  ████████     WM: KWin
 ████████  ████████  ████████     GTK Theme: Breath [GTK2/3]
 ████████  ████████  ████████     Icon Theme: breath2
 ████████  ████████  ████████     Disk: 171G / 1023G (18%)
 ████████  ████████  ████████     CPU: 11th Gen Intel Core i7-1185G7 @ 8x 4.8GHz [62.0°C]
 ████████  ████████  ████████     GPU: Mesa Intel(R) Xe Graphics (TGL GT2)
                                  RAM: 8299MiB / 31821MiB
  • docker info
➜  ~ docker info
Client:
 Context:    default
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 30
 Server Version: 20.10.7
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: false
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: xxxx.m
 runc version: v1.0.0-0-g84113eef
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.13.1-3-MANJARO
 Operating System: Manjaro Linux
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 31.08GiB
 Name: manjaro-xps
 ID: xxxx
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine
  • my experiment:
  1. that is Homemade image FROM centos7; ADD oracle jdk8_202
➜  ~ docker run --rm -m 1g houzw/cenots7_jdk8_202:v1 java -XshowSettings:vm -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram|UseContainerSupport"
    uintx DefaultMaxRAMFraction                     = 4                                   {product}
    uintx MaxHeapSize                              := 8342470656                          {product}
 uint64_t MaxRAM                                    = 137438953472                        {pd product}
    uintx MaxRAMFraction                            = 4                                   {product}
   double MaxRAMPercentage                          = 25.000000                           {product}
     bool UseContainerSupport                       = true                                {product}
VM settings:
    Max. Heap Size (Estimated): 6.91G
    Ergonomics Machine Class: server
    Using VM: Java HotSpot(TM) 64-Bit Server VM

java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
  1. I tried to use openjdk, the result is the same
➜  ~ docker run --rm -m 1g openjdk:8u191-jre-alpine java -XshowSettings:vm -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|maxram|UseContainerSupport"
    uintx DefaultMaxRAMFraction                     = 4                                   {product}
    uintx MaxHeapSize                              := 8342470656                          {product}
 uint64_t MaxRAM                                    = 137438953472                        {pd product}
    uintx MaxRAMFraction                            = 4                                   {product}
   double MaxRAMPercentage                          = 25.000000                           {product}
     bool UseContainerSupport                       = true                                {product}
VM settings:
    Max. Heap Size (Estimated): 6.91G
    Ergonomics Machine Class: server
    Using VM: OpenJDK 64-Bit Server VM

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (IcedTea 3.10.0) (Alpine 8.191.12-r0)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

I don't know where is the problem

Looking forward to the master's reply or solution ideas

Thank you wedm for your answer, but the problem I encountered is that MaxHeapSize cannot be affected by the -m parameter of docker。 I execute your same command in my system and it will look like this

➜  ~ docker run --rm -m 1g openjdk:8u191-jre-alpine java -XshowSettings:vm -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|UseContainerSupport"
    uintx MaxHeapSize                              := 8342470656                          {product}
     bool UseContainerSupport                       = true                                {product}
VM settings:
    Max. Heap Size (Estimated): 6.91G
    Ergonomics Machine Class: server
    Using VM: OpenJDK 64-Bit Server VM

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (IcedTea 3.10.0) (Alpine 8.191.12-r0)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
➜  ~ docker run --rm -m 2g openjdk:8u191-jre-alpine java -XshowSettings:vm -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|UseContainerSupport"
    uintx MaxHeapSize                              := 8342470656                          {product}
     bool UseContainerSupport                       = true                                {product}
VM settings:
    Max. Heap Size (Estimated): 6.91G
    Ergonomics Machine Class: server
    Using VM: OpenJDK 64-Bit Server VM

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (IcedTea 3.10.0) (Alpine 8.191.12-r0)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

In this case, jvm will continue to allocate heap memory until the container memory exceeds the -m limit, causing the container to be killed by the system

sirius
  • 11
  • 4

1 Answers1

0

-XX+UseContainerSupport only affects the max heap size, so that's the only parameter you should examine.

If your application is running in a container that imposes a memory limit, the VM allocates a larger fraction of memory to the Java heap. docs

Running a similar command did affect the max heap size on the openjdk image you mention:

with 1g:

docker run --rm -m 1g openjdk:8u191-jre-alpine java -XshowSettings:vm -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|UseContainerSupport"
    uintx MaxHeapSize                              := 268435456                           {product}
     bool UseContainerSupport                       = true                                {product}

with 2g:

docker run --rm -m 2g openjdk:8u191-jre-alpine java -XshowSettings:vm -XX:+PrintFlagsFinal -version | grep -Ei "maxheapsize|UseContainerSupport"
    uintx MaxHeapSize                              := 536870912                           {product}
     bool UseContainerSupport                       = true                                {product}
William Edmisten
  • 693
  • 5
  • 12