JVM memory allocation in a Docker container (LXC)

We launched the JVM application (Scala), Java 1.7, and are trying to decide how to allocate memory. We have one application running in a docker container. If the docker container is allocated 4 GB of RAM, should we allocate 4 GB (or maybe a little less to be safe) for the JVM?

As I understand it, there are no other processes in the docker container besides what is called from the entry point, so we do not need to worry about using memory other than the JVM - is this true or simplification? Are there any other questions we need to ask?

EDIT . We use Mesos / Marathon to deploy docker images. I suppose it sets limits on the group in memory (at least it gives the impression that it is), but I could definitely be wrong.

+7
java docker jvm
source share
3 answers

I have the same scenario and I use 90% of the reserved memory for jvm and work fine

+1
source share

For your question, handle your container in the same way as a process running on the host machine.

This is a process running on the host machine, albeit with its own namespaces for the network, process, etc.

You do not even "allocate" memory to the container; you can limit if you like through groups, but since the JVM has its own limit, this is not necessary.

Finally, in this situation, you control the use of virtual memory, not RAM.

0
source share

You cannot specify -Xmx the same value as container memory, because Java will require some space for permanent generation (permgen), code cache, etc. There is one tool for another container medium, Warden. The tool is here : I think it can be used inside Docker too. Need to test.

0
source share

All Articles