I use the spring-boot:build-image maven target for building a docker image of my Spring Boot application. I have following setup in my pom.xml
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<configuration>
<image>
<builder>paketobuildpacks/builder:full</builder>
<runImage>gcr.io/paketo-buildpacks/run:full-cnb</runImage>
<env>
<BP_JVM_VERSION>17</BP_JVM_VERSION>
<JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</JAVA_TOOL_OPTIONS>
</env>
</image>
</configuration>
</plugin>
How can I change the MaxDirectMemorySize? The JAVA_TOOL_OPTIONS environment doesn't work. I still get following console log output on startup:
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -Xmx1310134K -XX:MaxMetaspaceSize=275017K -XX:ReservedCodeCacheSize=240M -Xss1M (Total Memory: 2G, Thread Count: 250, Loaded Class Count: 46141, Headroom: 0%)
Picked up JAVA_TOOL_OPTIONS: -Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -XX:+ExitOnOutOfMemoryError -XX:ActiveProcessorCount=4 -XX:MaxDirectMemorySize=10M -Xmx1310134K -XX:MaxMetaspaceSize=275017K -XX:ReservedCodeCacheSize=240M -Xss1M -XX:+UnlockDiagnosticVMOptions -XX:NativeMemoryTracking=summary -XX:+PrintNMTStatistics -Dorg.springframework.cloud.bindings.boot.enable=true
How can I increase the max direct memory size? Thanks a lot!
I believe you are trying to apply a runtime configuration (JAVA_TOOL_OPTIONS) to build informations.
According to the spring documentation at https://docs.spring.io/spring-boot/docs/3.0.x/maven-plugin/reference/htmlsingle/#build-image.examples.runtime-jvm-configuration, you should change this to.
<env>
<BP_JVM_VERSION>17</BP_JVM_VERSION>
<BPE_APPEND_JAVA_TOOL_OPTIONS>-XX:MaxDirectMemorySize=64M</BPE_APPEND_JAVA_TOOL_OPTIONS>
</env>
Does that make it work for you?