To fix the java.lang.OutOfMemoryError: Java heap space
error, you can increase the maximum heap size allocated to the JVM. In your current configuration, you have set the initial heap size and maximum heap size to 5GB using the -Xms
and -Xmx
JVM options. However, this may not be sufficient for your application's memory requirements.
You can try increasing the maximum heap size to a higher value, such as 8GB or 10GB, and see if it resolves the issue. You can do this by modifying the -Xmx
option in your configuration.
- name: JVM_OPTS
value: -Xms5G -Xmx10G -XX:MaxMetaspaceSize=1024m -XX:ParallelGCThreads=16 -XX:+ExitOnOutOfMemoryError -javaagent:agent/applicationinsights-agent-3.4.12.jar
Keep in mind that setting the maximum heap size too high can also cause issues such as container OOM, so you need to find a balance between the memory requirements of your application and the available resources.
References: