-XX:MaxRAMPercentage isn’t working?

Paul Dally
Nov 22, 2023
Photo by Possessed Photography on Unsplash

Have you removed your -Xmx setting yet? Often (e.g. OpenJDK, IBM, Red Hat), if you specify both and -XX:MaxRAMPercentage, -Xmx will take precedence and -XX:MaxRAMPercentage will simply be ignored — although exceptions are starting to be introduced. If you are deploying your Java application to containers and your memory limits are less than the Xmx, you may find that your container continually restarts with an OOMKilled message. Even if not deploying to containers or you happen to be using a Java distribution that doesn’t prioritize -Xmx, specifying both Xmx and MaxRAMPercentage is confusing and misleading.

If you are using -XX:MaxRAMPercentage, please remove your -Xmx setting.

--

--

Paul Dally

AVP, IT Foundation Platforms Architecture at Sun Life Financial. Views & opinions expressed are my own, not necessarily those of Sun Life