How to set the Spring Boot conventions through JAVA_TOOL_OPTIONS and the Environment Variable for TBS in TAP
search cancel

How to set the Spring Boot conventions through JAVA_TOOL_OPTIONS and the Environment Variable for TBS in TAP

book

Article ID: 402716

calendar_today

Updated On:

Products

VMware Tanzu Application Platform

Issue/Introduction

The pod log is showing like the below:

Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx2953154K -XX:MaxMetaspaceSize=630845K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 4000M, Thread Count: 250, Loaded Class Count: 108963, Headroom: 0%)

 

Referred to https://paketo.io/docs/reference/java-reference/, we can know the JVM Memory Calculator.

Heap = Total Container Memory - Non-Heap - Headroom
Non-Heap = Direct Memory + Metaspace + Reserved Code Cache + (Thread Stack * Thread Count)

 

When hitting the JVM OOM issue, we would like to set the Spring Boot conventions through JAVA_TOOL_OPTIONS and the Environment Variable for TBS in workload.yaml.

Resolution

 

 

The workload.yaml example:

spec:
  resources:
    limits:
      memory: 4000Mi
  build:
    env:
    - name: BP_JVM_VERSION
      value: "17"
    - name: BP_MAVEN_BUILD_ARGUMENTS
      value: -Dmaven.test.skip=true -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true
        -Dmaven.wagon.http.ssl.ignore.validity.dates=true --no-transfer-progress package
  env:
  - name: SPRING_PROFILES_ACTIVE
    value: dev
  - name: JAVA_TOOL_OPTIONS
    value: -Delastic.apm.environment=dev -Dfile.encoding=UTF8 
      -XX:MaxMetaspaceSize=256M
  - name: BPL_JVM_CLASS_ADJUSTMENT
    value: 100%