且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

了解“缓冲区"和“已缓存"来自***命令

更新时间:2023-11-12 22:35:34

free命令中的列标题至少在Linux用户(与开发人员相对)的角度上被贴错了标签.以下是标题含义的说明:

The column headers in the free command are somewhat mislabeled, at least from the point of view of a linux user (as opposed to developer). Below is a clarification of what the headings mean:

总计:是的,这是总内存.

total: Yes, this is total ram.

使用过的:这可能是最混乱的列.这是应用程序使用的内存和其他临时"(缓冲区+缓存)使用的内存(如果需要的话)的混合物.因此,从技术上讲,内存是真正使用的内存,但是如果应用程序需要,则可以使用很多内存.如果Linux系统可用,则借用临时"使用的内存,以帮助提高系统性能,否则系统将更频繁地从磁盘读取数据.此类存储器的大部分显示在已缓存"列下.如果应用程序需要内存,则linux系统会放弃此内存.

used: This is probably the most confused column. This is a mix of application used memory and other 'temporarily' (buffer + cache) used memory that is actually available if needed. So technically the memory is truly being used, but much of this memory is available if an application needs it. The 'temporarily' used memory is borrowed if available by the linux system to help speed up system performance, otherwise the system would have read from disk more often. Much of this type of memory is shown under the 'cached' column. This memory is given up by the linux system if an application need memory.

免费:是的,这是完全免费且未曾改变的内存.

free: Yes, this pure free and untouched memory.

共享:专门分配给多个进程使用的内存

shared: Memory specifically allocated for use by multiple processes

缓冲区:为帮助某些进程而预留的临时内存

buffers: Temporary memory that is set aside to help some processes

缓存:操作系统可用和借用"的内存,以帮助加速许多Linux OS操作.如果应用程序需要,该内存将由系统放弃.

cache: Memory that is available and 'borrowed' by the operating system to help speed up many linux OS operations. This memory is given up by the system if an application need it.

-/+ buffers/cache 开头的行通常比 Mem 的第一行更有帮助. 免费-/+缓冲区/高速缓存的交集本质上就是您拥有可用"内存的条件.

The line that starts with -/+ buffers/cache is typically more helpful than the first Mem line. The intersection of free and -/+ buffers/cache is essentially what you have for 'available' memory.