Linux 释放内存方法 

 
先看看内存使用状况
[root@node1 ~]# free -m
total used free shared buffers cached
Mem: 8004 6557 1446 0 163 5630
-/+ buffers/cache: 763 7240
Swap: 1983 0 1983
把内存里的数据暂时写到硬盘里
[root@node1 ~]# sync
修改 /proc/sys/vm/drop_caches文件
[root@node1 ~]# echo 3 > /proc/sys/vm/drop_caches
[root@node1 ~]# cat /proc/sys/vm/drop_caches
再看内存
[root@node1 ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          4051       1649       2401          0        202       1239
-/+ buffers/cache:        208       3842
Swap:         5535          0       5535

[root@node1 ~]#free -m
             total       used       free     shared    buffers     cached
Mem:          4051        139       3911          0          0         21
-/+ buffers/cache:        117       3933
Swap:         5535          0       5535

[root@node1 ~]#