简体   繁体   English

为什么内存使用量超过Linux中的物理RAM?

[英]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. 我正在研究一个具有512MB RAM和足够交换内存的嵌入式系统来支持该应用程序。 From the kernel, I have restricted the RAM size from the kernel cmd argument to 130MB. 从内核中,我将内核cmd参数的RAM大小限制为130MB。 And disabled the swap using swapoff -a . 并使用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 . 我验证了/proc/cmdline/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!! 现在,当我运行应用程序并检查顶部值时,我的应用程序的VSZ是177m,这超过了实际的内存! How is this possible? 这怎么可能? Where did this memory came from? 这个记忆是从哪里来的?

VSZ is virtual memory size which is used by the process. VSZ是进程使用的虚拟内存大小。 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. 您应该查看Resident size(RSS),它是进程使用的实际物理内存。

Look at this example: 看看这个例子:

I have an nginx process running: 我有一个运行的nginx进程:

 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. 因此,这意味着此过程使用956kB的物理内存和31MB的虚拟内存。

Disabling swap (swapoff -a), like you did, doesn't disable using virtual memory. 与您一样,禁用交换(swapoff -a)不会禁用虚拟内存。

Read about virtual memory here: Virtual memory 在这里阅读虚拟内存: 虚拟内存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM