Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upBest practices for JVM memory management in Docker containers #361
Labels
Comments
|
@PaulSandoz FYI, could not find Mikael's github handle. |
|
I suppose this is the link |
|
Would love to see points on how to estimate how much off-heap memory is typically needed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Which lab is it that you're having issues with?
Lab: Docker for Java Developers
Description
When deploying Java applications in production one usually specifies the amount of memory available to the JVM (-Xmx) and other assorted configuration settings. Unfortunately, this is (usually) static configuration and therefore fixed in the container image. When specifying memory constraints (using cgroups) this is unfortunately not picked up by the JVM automatically, so there should be a section on memory management for dockerized Java apps.
Java9 and Java8 > u131 provide limited support for this, see https://bugs.openjdk.java.net/browse/JDK-8170888 for details.
For older Java releases there is a good script from @fabric8io-images: https://github.com/fabric8io-images/java/blob/master/images/centos/openjdk8/jdk/container-limits
Also, it is not easy to calculate the amount of JVM heap and the resulting cgroup limits, as the JVM also needs memory for other things, e.g. metaspace, JIT, ...
A few words on the whole topic of JVM memory management for containers would be a very good addition. Articles like https://developers.redhat.com/blog/2017/03/14/java-inside-docker/ provide a good starting point.