在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/Linux  網(wǎng)絡(luò)安全/ Ubuntu 使用free命令used != total - free

Ubuntu 使用free命令used != total - free

使用free -m命令:

              total        used        free      shared  buff/cache   available
Mem:            992         425          90          15         476         363
Swap:          2047           7        2040

可用內(nèi)存=系統(tǒng)free memory+buffers+cached
這里不滿足:
used=total-free 即 total=used+free
??

回答
編輯回答
詆毀你

找了一些內(nèi)容來(lái):

3.14內(nèi)核新增了一個(gè)內(nèi)存信息MemAvailable , 當(dāng)調(diào)用free命令時(shí)可以顯示為available
之前沒(méi)留意過(guò)

[root@VM_167_46_centos etc]# free -h
                         total         used             free      shared     buff/cache      available
Mem:           993M        253M        334M         39M               405M             556M
Swap:           2.0G          82M             1.9G

我們知道used + free + buff 基本等于 total

  • used是被使用的
  • free是完全沒(méi)有被使用的
  • shared是被程序之間可以(已經(jīng)被)共享使用的
  • buffers是指用來(lái)給塊設(shè)備做的緩沖大小,它只記錄文件系統(tǒng)的metadata以及 tracking in-flight pages
  • cached是用來(lái)給文件做緩沖

也就是 buffers是用來(lái)存儲(chǔ)目錄里面有什么內(nèi)容,權(quán)限等等。而cached直接用來(lái)緩存我們打開(kāi)的文件
available到底是什么

Many load balancing and workload placing programs check /proc/meminfo to estimate how much free memory is available. They generally do this by adding up "free" and "cached", which was fine ten years ago, but is pretty much guaranteed to be wrong today.
It is wrong because Cached includes memory that is not freeable as page cache, for example shared memory segments, tmpfs, and ramfs, and it does not include reclaimable slab memory, which can take up a large fraction of system memory on mostly idle systems with lots of files.Currently, the amount of memory that is available for a new workload,without pushing the system into swap, can be estimated from MemFree, Active(file), Inactive(file), and SReclaimable, as well as the "low"watermarks from /proc/zoneinfo.However, this may change in the future, and user space really should not be expected to know kernel internals to come up with an estimate for the amount of free memory.It is more convenient to provide such an estimate in /proc/meminfo. If things change in the future, we only have to change it in one place.

也就是說(shuō)available才是你的"可用內(nèi)存" , 而不是像過(guò)去那樣簡(jiǎn)單的把free和buffer加起來(lái)

available 小于 free+buffer 是一定的了

2018年8月13日 10:58
編輯回答
亮瞎她

計(jì)算公式應(yīng)該是 used = total - free - buffers - cache
man free就可以看到了

2018年4月16日 13:32