-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
15.0.2
-
x86_64
-
linux
ADDITIONAL SYSTEM INFORMATION :
using containerd 1.4.4
A DESCRIPTION OF THE PROBLEM :
When using containerd to run java in a container the total physical memory should be based on the cgroup's limit in bytes as described here:JDK-8146115
This works correctly when the container is run using docker but not when it is run using containerd
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
# Running on a machine with 4GB of RAM
docker run --rm --memory 1000000000 --entrypoint bash docker.io/library/openjdk:15-jdk-slim -c "echo 'System.out.println(\"TotalPhysicalMemorySize: \" + ((com.sun.management.OperatingSystemMXBean)java.lang.management.ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize())' | jshell -"
> TotalPhysicalMemorySize: 999997440
# This is correct!!
sudo ctr run --rm --memory-limit 1000000000 docker.io/library/openjdk:15-jdk-slim java bash -c "echo 'System.out.println(\"TotalPhysicalMemorySize: \" + ((com.sun.management.OperatingSystemMXBean)java.lang.management.ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize())' | jshell -"
> TotalPhysicalMemorySize: 4126633984
# This incorrect - it is the machine's memory, not the container's
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The reported physical memory size should be the same when using containerd with a memory limit or docker with a memory limit
ACTUAL -
when using containerd the host machine's memory is reported not the docker container's memory
FREQUENCY : always
using containerd 1.4.4
A DESCRIPTION OF THE PROBLEM :
When using containerd to run java in a container the total physical memory should be based on the cgroup's limit in bytes as described here:
This works correctly when the container is run using docker but not when it is run using containerd
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
# Running on a machine with 4GB of RAM
docker run --rm --memory 1000000000 --entrypoint bash docker.io/library/openjdk:15-jdk-slim -c "echo 'System.out.println(\"TotalPhysicalMemorySize: \" + ((com.sun.management.OperatingSystemMXBean)java.lang.management.ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize())' | jshell -"
> TotalPhysicalMemorySize: 999997440
# This is correct!!
sudo ctr run --rm --memory-limit 1000000000 docker.io/library/openjdk:15-jdk-slim java bash -c "echo 'System.out.println(\"TotalPhysicalMemorySize: \" + ((com.sun.management.OperatingSystemMXBean)java.lang.management.ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize())' | jshell -"
> TotalPhysicalMemorySize: 4126633984
# This incorrect - it is the machine's memory, not the container's
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The reported physical memory size should be the same when using containerd with a memory limit or docker with a memory limit
ACTUAL -
when using containerd the host machine's memory is reported not the docker container's memory
FREQUENCY : always