2012/2/6

flush the memory space of cache

In Linux, you can clear the cache of the memory by using
free pagecache
echo 1 > /proc/sys/vm/drop_caches


free dentries and inodes
echo 2 > /proc/sys/vm/drop_caches
free force cache
echo 3 > /proc/sys/vm/drop_caches

At last, remember to type
echo 0 > /proc/sys/vm/drop_caches
echo 0 > /proc/sys/vm/drop_caches
Another method, 
Method 2:

echo 1 > /proc/sys/vm/drop_caches
    or
sysctl -w vm.drop_caches=1

Method 3:
fcntl(fd, F_SETFL, O_DIRECT)

Method 4:
sysctl -w vm.vfs_cache_pressure=n  (n > 100)

this make kernel to free cache frequencily.