在我刚刚接触Linux时就知道了top这个命令,后来又发现了图形界面下类似Windows任务管理器的System Monitor,但我发现二者在内存的统计方面有很大的不同,SEE:
注意Mem处的used,再看System Monitor
仔细观察会发现,top的Mem used和System Monitor的差别很大,后来才知道,System Monitor的Mem是==used-cached,计算下确实如此,再回过头来看看man top,同时水木上一位大哥给我介绍说:
The memory meter in htop says a low number, such as 9%, when top shows
something like 90%! (Or: the MEM% number is low, but the bar looks almost full.
What’s going on?)
The number showed by the memory meter is the total memory used by processes.
The additional available memory is used by the Linux kernel for buffering and
disk cache, so in total almost the entire memory is in use by the kernel. I
believe the number displayed by htop is a more meaningful metric of resources
used
—–
htop的作者的解释
看完顿时受益良多,二者其实都正确,只不过是对于内存的使用方式理解不同罢了。