Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why memory usage is more than physical RAM in Linux?

I am working on an embedded system with 512MB of RAM and enough swap memory to support the application. From the kernel, I have restricted the RAM size from the kernel cmd argument to 130MB. And disabled the swap using swapoff -a. I also disabled kernel overcommit, so that the application can run in physical memory alone. I verified the changes from /proc/cmdline and /proc/meminfo. Now when I run the application and check the top values, VSZ for my application is 177m which is more than the actual memory!! How is this possible? Where did this memory came from?

like image 499
jsaji Avatar asked Oct 22 '14 05:10

jsaji


1 Answers

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

Look at this example:

I have an nginx process running:

 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, it means this process is using 956kB of physical memory, and 31MB of virtual memory.

Disabling swap (swapoff -a), like you did, doesn't disable using virtual memory.

Read about virtual memory here: Virtual memory

like image 152
RaFD Avatar answered Oct 03 '22 08:10

RaFD