Saturday, October 4, 2008

Linux - Free cache memory

Free Memory by dropping caches

To use /proc/sys/vm/drop_caches, just echo a number to it.

To free pagecache: Freeing

# 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:

# echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable, run sync first!

Here are the before and after results from my desktop:

# free              total       used       free     shared    buffers     cached Mem:       2074840    1656052     418788          0     140108     907920 -/+ buffers/cache:     608024    1466816 Swap:      3911816      76436    3835380  # sync ; echo 3 > /proc/sys/vm/drop_caches ; free              total       used       free     shared    buffers     cached Mem:       2074840     698472    1376368          0        268     126488 -/+ buffers/cache:     571716    1503124 Swap:      3911816      76436    3835380
Thanks to http://linux-mm.org
Best Regards,
http://feeds.feedburner.com/rameshr

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------