Linux under clean-up system cache and free up memory

Linux under clean-up system cache and free up memory

Cache data storage location

Once in Linux frequently accessed files, physical memory will soon be exhausted, when the program ends, the memory will not be a normal release, but has been as caching
and therefore we do need to clean up the system manually release the memory cache.

1, we should first clear the cache before the next sync

sync

Because the system is in the process of operation, the operation will take you to the documents stored in the first buffer to go, for fear you because of power outages and other causes of data loss during the operation, so you will documents in the course of operation first cache.
So we need to put data in the first write buffe clear the cache to the hard drive, sync command

sync
manually sync command execution (Description:. sync command to run the sync subroutine If you must stop the system, run the sync command to ensure the integrity of the file system .sync command of all unwritten system buffers written to disk, it contains modified i-node, the delayed block I / O read and write, and mapping file)

2, enter the command manually release the memory

echo 3 > /proc/sys/vm/drop_caches 

Drop_caches value may be different between the figures 0-3, the representative meanings:

0:不释放(系统默认值)
1:释放页缓存
2:释放dentries和inodes

3, now it has released all cache

4, free -h to see whether the memory has been freed

total——总物理内存
used——已使用内存,一般情况这个值会比较大,因为这个值包括了cache+应用程序使用的内存
free——完全未被使用的内存
shared——应用程序共享内存
buffers——缓存,主要用于目录方面,inode值等(ls大目录可看到这个值增加)
Published 23 original articles · won praise 0 · Views 1453

Guess you like

Origin blog.csdn.net/weixin_45775343/article/details/102702495