zoe
zoe copied to clipboard
A JVM in Docker with memory limits can get OOM killed
When a container is limited in memory, the processes inside the container still see the full amount of memory available in the system when they use the OS system calls. Java relies on the OS information and will try to use more memory than the limit imposed in the container.
This will happen always, sooner or later, regardless of how high you set the limit, or the the use of the various -X options to the java executable. More information is available here:
- http://matthewkwilliams.com/index.php/2016/03/17/docker-cgroups-memory-constraints-and-java-cautionary-tale/
- http://trustmeiamadeveloper.com/2016/03/18/where-is-my-memory-java/
- https://github.com/docker/docker/issues/15020
- https://fabiokung.com/2014/03/13/memory-inside-linux-containers/
This is not a Zoe issue, but with Docker and the Linux container system. It affects Zoe applications, so we will keep track of workarounds and solutions here.
Found more material directly from the RedHat developers Blog: https://developers.redhat.com/blog/2017/03/14/java-inside-docker/
The DockerEngine backend uses soft memory limits to try to limit this issue to cases where the JVM is really allocating too much memory. Another idea that we are investigating is: https://linuxcontainers.org/lxcfs/introduction/