This topic describes the cause of the following issue and how to resolve the issue: The free command output indicates that the memory usage of a container running on an Alibaba Cloud Linux 3 host is higher the memory usage of the host.
Problem description
The memory usage of a container that is deployed on a host running Alibaba Cloud Linux 3 is higher than the memory usage of the host.
Cause
Memory usage is calculated by using the following formula: mem_used = kb_main_total - kb_main_free - kb_main_cached - kb_main_buffers, which does not properly treat shared memory (shmem). As a result, the calculated memory usage of the container is inaccurate.
Shared memory is a memory region that has the properties of anonymous pages and page cache and cannot be reclaimed as free memory when no swap space is configured. Shared memory (shmem) must be regarded as memory in use, instead of free memory to be included in the value of the kb_main_free parameter in the preceding formula. To obtain the accurate amount of memory in use (mem_used), exclude shared memory from the value of the kb_main_free parameter in the formula.
Solution
Run the following command on the host to update procps-ng to version 3.3.15-14.0.3.al8 or later:
sudo yum update procps-ng Update procps-ng to make the new formula used to calculate memory usage take effect and resolve the preceding issue. For information about procps, see procps-ng>procps.