correct jvm params setting in container

5/13/2020

I have a spring-boot(V1.5.22) project and package it as war. My docker base image is Zulu 25.222-b10.

JAVA_OPTS= -XX:InitialRAMPercentage=75.0 -XX:MaxRAMPercentage=80.0
-XX:MinRAMPercentage=25.0 -XX:+UseG1GC -XX:+UseStringDeduplication  
-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap 
-XX:+UseContainerSupport-XshowSettings:vm`

I print the memory.limit_in_bytes in entrypoint.sh;

cat /sys/fs/cgroup/memory/memory.limit_in_bytes
536870912`,equal `512Mi` as I given in k8s yaml file `{resource.limit}`

the param -XshowSettings:vm feed me back VM info print out in the console

VM settings:
    Max. Heap Size (Estimated): 410.00M
    Ergonomics Machine Class: server
    Using VM: OpenJDK 64-Bit Server VM`

but it was killed:

entrypoint.sh: line 161:  3292 Killed
sudo -u itsma -E /usr/lib/jvm/zulu-8-amd64/bin/java ${JAVA_OPTS} -jar /app.war --pod ${HOSTNAME}

I guess it is OOM, but the max heap size is already 410M. Can someone provide some ideas

-- 袁文涛
docker
java-8
jvm
kubernetes
spring-boot

0 Answers