--释放前,free的值比较小了[root@develop ~]# free -m total used free shared buffers cachedMem: 64378 59984 994 0 1908 51181-/+ buffers/cache: 10294 54083Swap: 32255 9 32246同步过程
--将缓存数据先刷到磁盘[root@develop ~]# more /proc/sys/vm/drop_caches0[root@develop ~]# sync[root@develop ~]# echo 1 > /proc/sys/vm/drop_caches[root@develop ~]# free -m total used free shared buffers cachedMem: 64378 18034 46344 0 4 8986-/+ buffers/cache: 9042 55335Swap: 32255 9 32246--重新改回去[root@develop ~]# echo 0 > /proc/sys/vm/drop_caches其他说明:
/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 becomefree.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 objectsare not freeable, the user should run sync(8) first.这个办法并不是一个治标的办法,不过可以结合ulimit来限制用户的内存分配 参考: http://hi.baidu.com/xingxuejun/item/36be551db5224f16e2f9864a