Linux free shows high memory usage but top does not

僤鯓⒐⒋嵵緔 提交于 2019-12-02 14:11:41

Don't look at the "Mem" line, look at the one below it.

The Linux kernel consumes as much memory as it can to provide the I/O cache (and other non-critical buffers, but the cache is going to be most of this usage). This memory is relinquished to processes when they request it. The "-/+ buffers/cache" line is showing you the adjusted values after the I/O cache is accounted for, that is, the amount of memory used by processes and the amount available to processes (in this case, 578MB used and 7411MB free).

The difference of used memory between the "Mem" and "-/+ buffers/cache" line shows you how much is in use by the kernel for the purposes of caching: 7734MB - 578MB = 7156MB in the I/O cache. If processes need this memory, the kernel will simply shrink the size of the I/O cache.

Also, as the first line shows total used free shared buffers cached Mem: 7989 7734 254 0 28 7128 -/+ buffers/cache: 578 7411

If we add (cached[7128] + buffers[28] + free[254]), we will get approximately the second line's free[7411] value 7128 + 28 + 254 = 7410

If the cached is small, try this command:

ps aux --sort -rss
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!