When using Linux, you will find a very strange problem: after using the TOP command for a period of time (especially after file copying and other operations), you will find that the memory is basically occupied, in addition, Linux will not be released. This problem has indeed plagued us. We began to look for ways to manually release the memory. We did find it, and it also produced my previous blog. Internet search also found that many people have this problem, but after a comprehensive analysis of the online results and my own understanding, it is concluded that the manual release of memory in Linux is a completely false proposition.
First, explain the meaning of each top option:
Total: physical memory available for all applications
Free: memory not used by the application
Used: memory used
Total = free + used
Shared: Shared Memory occupied by the shared library
Buffers: Memory Used for file Buffering
Cached: kernel buffer virtual memory
Shared, buffers, and cached are included in used.
In fact, after the kernel finishes a program, it will release the memory, but the kernel does not immediately collect this part into free, but exists in cached or buffer, improves the system's Io efficiency. The cache and buffered memory are dynamically configured and managed by the kernel. If the system's free size is insufficient, the system automatically releases the cache buffer memory for the program. (If you see a lot of used, it is not necessary to manually release the memory)
That is to say, Linux will use as much memory as possible to improve the system speed and IO efficiency, but it has a corresponding mechanism to release the memory, in fact, we can simply understand that cache and buffer are free space.
When does it mean that your memory is not enough? That is, there are a lot of used, but the proportion of cache and buffer is very small, indicating that the memory is not enough. Many netizens said that used accounts for a lot and free is rarely uncomfortable. Simple psychology: the more free memory, the happier it looks ?? Yes ?? We recommend that GNU display the free memory as the sum of cached and buffer. Let's say: Linux memory is used, and Windows Memory is used for viewing.