Linux释放caching的内存

root@server ~]# free -m
total       used       free     shared    buffers     cached
Mem:           249        163         86          0         10         94
-/+ buffers/cache:         58        191
Swap:          511          0        511
其中:
total 内存总数
used 已经使用的内存数
free 空闲的内存数
shared 多个进程共享的内存总额
buffers Buffer Cache和cached Page Cache 磁盘缓存的大小
-buffers/cache 的内存数:used - buffers - cached
+buffers/cache 的内存数:free + buffers + cached
可用的memory=free memory+buffers+cached
 
通过修改/proc/sys/vm/drop_caches的值即可释放cache的内存
[root@server test]# echo 3 > /proc/sys/vm/drop_caches
[root@server test]# cat /proc/sys/vm/drop_caches
3
/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing  to  this  file  causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory  to  become free.
To  free  pagecache,  use  echo 1 > /proc/sys/vm/drop_caches;
to  free  dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to  free  pagecache,   dentries  and  inodes,  use  echo  3  > /proc/sys/vm/drop_caches.
Because this is a non-destructive operation  and  dirty  objects

posted on 2012-06-01 11:02  fergus.y.m  阅读(175)  评论(0)    收藏  举报