1、查看系统中的cache
[root@VM_0_11_centos log]# free
total used free shared buff/cache available
Mem: 1916008 340332 102432 572 1473244 1387476
Swap: 0 0 0
[root@VM_0_11_centos log]# cat /proc/sys
2、/proc/sys/vm/drop_caches
[root@VM_0_11_centos log]# cat /proc/sys/vm/drop_caches
0
[root@VM_0_11_centos log]#
Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache...
To use /proc/sys/vm/drop_caches, just echo a number to it.
To free pagecache:
# echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes: