Discrepancy in RAM usage?

Hi there,

I recently posted a separate topic regarding the high RAM usage I was seeing in my deployed application (Out of memory error - #6 by dimitriborgers): For further research, I compared two applications to see why one was using much more RAM than the other.

One is marked as using ~92 MB in the metrics pane, and outputs the following on “free -m”:

render@srv-c3cf3qvvf37ommnlib60-b7c9cbd4c-kjvzn:~/project/src$ free -m
                 total        used        free      shared  buff/cache   available
Mem:             42148        19026       1938      117     21183        24606
Swap:                0            0          0

Another is marked as using ~400 MB in the metrics pane, and outputs the following on “free -m”:

I’m not quite sure I understand why one is marked as 92MB and the other is 400MB, when both have very similar levels of “used” memory (as well as “buff/cache”, though I don’t think that should be counted as used memory). What am I missing that would explain the discrepancy?

Hi @dimitriborgers ,

This is a great question, since it can be pretty confusing to see these numbers. All services hosted on Render are hosted in containers, like Docker containers, that run on larger virtual machines. This means that while your service may only have access to 512 MB of memory, the container it’s running in might be running on a virtual machine with a lot more memory.

The free command is misleading because it reports memory usage of the virtual machine, not the container. Your free command, for example, shows that there’s 42148 total MiB of memory, or 41 GiB, which is shared across all of the containers running on the same virtual machine.

To see the memory used by your service instance itself, you can look at the /sys/fs/cgroup/memory/memory.stat file. For example, if you run cat /sys/fs/cgroup/memory/memory.stat in your service’s shell, you might see total_rss 387436544, where “rss” refers to “resident set size” memory. 387436544 bytes is about equal to 369 MiB, which should match much closer to what you’re seeing in the metrics pane.

Hopefully this helps clear things up!

4 Likes

Sure helpful @dan , thank you!