Manually release memory in CentOS
For a Web server at the backend of the online cluster, we have observed that the + buffers/cache value (actual usage of Linux memory) is always around 5365, even if the Nginx + FastCGI program is stopped, considering that this machine is often using rsync + inotify, there will certainly be frequent file access. In Linux, files are frequently accessed in Linux, which occupies physical memory. When the program ends, it will not automatically release the occupied memory, but will always exist as a Cache. 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 will automatically release the cache buffer memory for the Program (so if you see a lot of used, it is not necessary to manually release the memory, my previous articles and books actually show how we can observe the actual memory usage of the Linux system ).
Procedure:
1. query the current memory usage and cache release parameters.
Free-m
The command result is shown in:
TotalusedfreesharedbufferscachedMem: 109886792419601681001-/+ buffers/cache: 56225365 Swap: 429504295
The command for viewing the release cache parameters is as follows:
Cat/proc/sys/vm/drop_caches
0
0 is the default value, indicating not to release.
2. Use the sync command to write dirty data in the system cache area to the disk, including modified I-node, delayed block I/O, and read/write ing files. The command is as follows:
Sync
3. The configuration file/proc/sys/vm/drop_caches records the cache release parameters. The command is as follows:
Echo3>/proc/sys/vm/drop_caches
4. Do not restart the machine to make the configuration change take effect. The command is as follows:
Sysctl-p
After the above operations are performed, the value of + buffers/cache has increased from 5365 to about 9000, and the value returns to normal. However, I think the Linux memory management method is actually excellent, in many cases, you do not need to manually release the memory.
This article from the "fuqin liquor" blog, please be sure to keep this source http://yuhongchun.blog.51cto.com/1604432/1430026