I ran this command which I found in this blog.
docker run -m 1GB openjdk:10 java \
-XX:+UseContainerSupport \
-XX:MinRAMPercentage=50 \
-XX:MaxRAMPercentage=80 \
-XshowSettings:vm \
-version
My output is this.
VM settings:
Max. Heap Size (Estimated): 3.86G
Using VM: OpenJDK 64-Bit Server VM
openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Debian-2)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Debian-2, mixed mode)
I am little bit confused now is that , when I limit the memory to 1G, why does Java see 3.86G or What needs to be done to make java see container memory limits ?
Note: I am on MAC. docker creates container inside the VM. So not sure if it matters.
-XX:+UseContainerSupport? It's supposed to be enabled by default, but maybe it's disabled somehow.