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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With