I’ve an application running on k8s and would like to updated the java heapsize . I’ve updated the JAVA_OPTS environnement variable and set it in the deployment file as below
- name: JAVA_OPTS value: "-Xmx768m -XX:MaxMetaspaceSize=256m"
but when i run the below command it looks like my changes does not takes effect
java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize' intx CompilerThreadStackSize = 0 {pd product} uintx ErgoHeapSizeLimit = 0 {product} uintx HeapSizePerGCThread = 87241520 {product} uintx InitialHeapSize := 33554432 {product} uintx LargePageHeapSizeThreshold = 134217728 {product} uintx MaxHeapSize := 536870912 {product} intx ThreadStackSize = 1024 {pd product} intx VMThreadStackSize = 1024 {pd product} openjdk version "1.8.0_212" OpenJDK Runtime Environment (IcedTea 3.12.0) (Alpine 8.212.04-r0) OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
I’m i wrong can someone help me and explain how to set hose values ?
Advertisement
Answer
I see that you used OpenJDK Alpine to deploy a JAVA application, so you need to use this environment “JAVA_TOOL_OPTIONS” instead of “JAVA_OPTS“, something like:
spec: containers: - name: jvm_options image: xxx:xxx env: - name: JAVA_TOOL_OPTIONS value: "-Xmx768m -XX:MaxMetaspaceSize=256m"
Once your application is running, you can check the application log and you will find the log below:
Picked up JAVA_TOOL_OPTIONS: -Xmx768m -XX:MaxMetaspaceSize=256m