为什么在Linux中内存使用量大于物理RAM? [英] Why memory usage is more than physical RAM in Linux?

查看:398
本文介绍了为什么在Linux中内存使用量大于物理RAM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个具有512MB RAM和足够交换内存以支持该应用程序的嵌入式系统上工作.在内核中,我将RAM的大小从kernel cmd参数限制为130MB.并使用swapoff -a禁用交换.我还禁用了内核过量使用,以便应用程序可以仅在物理内存中运行.我验证了/proc/cmdline/proc/meminfo的更改.现在,当我运行该应用程序并检查最高值时,我的应用程序的VSZ为177m,比实际内存还多!!这怎么可能?这种记忆是从哪里来的?

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是进程使用的虚拟内存大小.通常,它大于物理内存的大小,因为这是其中的主要思想之一.您应该查看驻留大小(RSS),它是该进程使用的实际物理内存.

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.

看这个例子:

我正在运行一个nginx进程:

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

因此,这意味着此过程正在使用956kB的物理内存和31MB的虚拟内存.

So, it means this process is using 956kB of physical memory, and 31MB of virtual memory.

像您一样,禁用交换(swapoff -a)不会禁用使用虚拟内存.

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

在此处了解有关虚拟内存的信息: 虚拟内存

Read about virtual memory here: Virtual memory

这篇关于为什么在Linux中内存使用量大于物理RAM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆