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.


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.


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?"

  • Consider using AWS Cloudwatch Container Insights: docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/…
    – Tim
    Commented Sep 29, 2020 at 18:45
  • @Tim there are more direct APIs that can be used for that. It's possible to query exactly how much memory is allocated to a task definition, for instance. But there's not much simple about that option as it requires installing AWS CLI and/or otherwise handling API authentication within the container.
    – hemp
    Commented Sep 29, 2020 at 21:10
  • Agree it's not a simple option, but I came across it this morning while poking around the CloudWatch console for something else. Containers tend to be fairly opaque as they're auto-scaled and not regularly logged into.
    – Tim
    Commented Sep 29, 2020 at 22:26

1 Answer 1

grep hierarchical_memory_limit /sys/fs/cgroup/memory/memory.stat

I believe this does it


hierarchical_memory_limit - # of bytes of memory limit with regard to hierarchy under which the memory cgroup is

So this seems to be the memory allocated to the container. You can also find allocated hard limits and soft limits

cat /sys/fs/cgroup/memory/memory.soft_limit_in_bytes
cat /sys/fs/cgroup/memory/memory.hard_limit_in_bytes

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .