Our task definition sets Task Memory to 8192MiB. Its sole docker container running Debian is configured with no memory limits.
In the bootstrap, we call cat /proc/meminfo
and get a report that shows:
MemTotal: 15649752 kB
MemFree: 13246500 kB
MemAvailable: 15126708 kB
Why is MemTotal reporting nearly two times the size of the task limit? I tried a similar run with task memory set to 2048MiB and /proc/meminfo reported about 3300MB - so a similar inflation.
UPDATE:
The explanation from AWS Support is that the containers are reporting the size of their host machine. So in this case it is presumably a 16GB host machine with some memory hidden from the container by the host. I'm not knowledgeable on the Docker architecture used by ECS, so not entirely sure why it doesn't report the full 16GB.
REVISED QUESTION:
Given that information, my revised question boils down to "What is the simplest method to get the actual memory available to the container, from within the container?" And a follow-up question, "Is it possible to forcibly change the value reported by OS API calls (Debian in this case) which report on total memory so that it accurately reflects what is available?"
I believe this does it
https://www.kernel.org/doc/Documentation/cgroup-v1/memory.txt
So this seems to be the memory allocated to the container. You can also find allocated hard limits and soft limits