I am trying to get a service running in a container, but ran into the OutOfMemoryError: Java heap space when the service in the container starts up (it does some memory intensive stuff).
I am trying to add the options for -Xmx1024 -Xms1024, but that didn't work.
I also attempted to use
-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
as the OpenJDK Docker Hub documentation mentions, however when I run that, it fails with the following error:
Unrecognized VM option 'UnlockExperimentalVMOptions XX:+UseCGroupMemoryLimitForHeap'
The current Dockerfile that I am using looks like the following
FROM openjdk:8u131
...
...
CMD ["java","-XshowSettings:vm -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap","-jar", "target/my-jar.jar"]
OpenJDK 10 and up detect the cgroup limit automatically without any additional flags (JDK-8146115). In addition they also let you specify the maximum heap size as fraction of that limit via the MaxRAMPercentage option (JDK-8186248).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With