7

Docs say:

Under this configuration, when the container consumes memory more than 200M and less than 500M, the next system memory reclaim attempts to shrink container memory below 200M.

But what does this actually mean?

Let's say I have a container running Solr, and:
docker run -m 1G --memory-reservation 768M solr

What effect does it have on the Solr process inside the container when it starts using 800M memory? Nothing?

Is it only if/when memory usage subsequently drops below 768M... this flag allows docker to reclaim the memory from the solr container? ...otherwise the container would continue to consume whatever the high-water memory usage was?

How does this relate to swarm scheduling? If swarm always allocates 1G for the container because of -m then is --memory-reservation not useful in this context?

  • I have a related question, what happens if a container runs above the soft limit, below the hard limit and the memory is being reclaimed? Will it be killed or keep running? – Martin Höger Nov 15 '17 at 12:02
  • I have no idea. But the link from @flo woo's answer (linux-mm.org/PageOutKswapd) seems like the 'reclaim' of memory involves paging to swap i.e. what I used to know in Windows 95 days as "virtual memory". So from this I would guess that the container is not killed, it will just get slow. – Anentropic Nov 15 '17 at 14:10
6

the memory-reservation option is a wrapper for the cgroup option called memory.soft_limit_in_bytes. You can read the (outdated) manual under the 'Soft limits' section: http://elixir.free-electrons.com/linux/latest/source/Documentation/cgroup-v1/memory.txt

More info on the reclaim process is here: http://linux-mm.org/PageOutKswapd

From what i can tell, your Solr process can use 800MB and as long as there is no contention from other cgroups then memory won't be reclaimed. It can keep the memory and use up to the hard limit of 1GB. If there is contention then the kernel will attempt to reclaim the memory but as per the doc's soft limits is a best-effort feature.. no guarantees.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.