2009年12月30日星期三

(RedHat, CentOS,OEL)手動清理memory的實驗

環境是CentOS5.2

[root@test ~]# free –m
                        total       used       free     shared    buffers     cached
Mem:         15721      14056       1664          0        533      11283
-/+ buffers/cache:       2239      13481
Swap:        16386          0      16386
[root@test ~]# sync;sync;sync
[root@test~]# echo 3 > /proc/sys/vm/drop_caches
[root@test~]# free –m
                      total       used       free     shared    buffers     cached
Mem:         15721       1837      13883          0          0         44
-/+ buffers/cache:       1792      13928
Swap:        16386          0      16386
[root@LITHIUM ~]#

explain:

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
are not freeable, the user should run sync(8) first.

没有评论:

发表评论