0

I'm running a java application on Kubernetes and the container shuts down due to a memory problem.

Is it possible for a java app running these envs to exceed 6GB of memory used? If so, would you please provide some of the most common reasons?

2023-05-16T23:33:12.293434619+02:00 stdout F JAVA_OPTS: -server -Xms2048m -Xmx3448m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=512m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -Djboss.bind.address=0.0.0.0 -Xlog:gc*::time --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED

I've tried searching for a way to limit the total memory allocated by the application and expected to use this knowledge, but found nothing.

  • 1
    Depending on what the container does, there is the possibility that java also allocates native memory (e.g. netty has a dependency to do so in certain situations). How exactly is the pod terminated? Does kubernetes kill the pod due to not respecting the memory limit, or does the java process fail with an error? – Turing85 May 18 '23 at 14:24
  • For modern java in containers you generally should not specify `-Xms` or `-Xmx` instead you should use `-XX:MaxRAMPercentage` and `-XX:InitialRAMPercentage` (or stick with the defaults which are good for most workloads). See: https://www.ibm.com/docs/en/sdk-java-technology/8?topic=options-xx-usecontainersupport – jordanm May 18 '23 at 18:08
  • Also as the other user noted, this only impacts heap memory, not all memory used. – jordanm May 18 '23 at 18:09

0 Answers0