Why is memory usage more than physical RAM in Linux?

I am working on an embedded system with 512 MB of RAM and enough memory to support the application. From the kernel, I limited the size of RAM from the kernel cmd argument to 130 MB. And turned off the exchange using swapoff -a . I also disabled kernel overcommit so that the application can only work in physical memory. I checked the changes from /proc/cmdline and /proc/meminfo . Now, when I run the application and check the upper values, the VSZ for my application is 177 m, which is more than real memory! How is this possible? Where did this memory come from?

+6
source share
1 answer

VSZ is the size of virtual memory that is used by the process. It’s normal that it is higher than the size of your physical memory, because this is one of the main ideas of this. You better look at the resident size (RSS), which is the actual physical memory used by the process.

Take a look at this example:

I have a nginx process:

  ps -o rss,vsz,cmd ax | grep -i nginx | head -n1 956 31248 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf rss - 956 kB vsz - 31248 kB 

So, this means that this process uses 956 KB of physical memory and 31 MB of virtual memory.

Disabling swap (swapoff -a), like you, does not disable the use of virtual memory.

Read about virtual memory here: Virtual memory

+6
source

Source: https://habr.com/ru/post/977059/


All Articles