how to totally clear the filesytem's cache on linux?
18,387
(it actually drops so..) run sync
first, then
free pagecache:
echo 1 > /proc/sys/vm/drop_caches
free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
Then you can start with a clean cache, but of course caching will still work.
Related videos on Youtube
Author by
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
In a performance test, I want to bypass the influence of cache of linux system (including page cache/inode cache and so on).
I have tried O_DIRECT flag, but it's turned out that direct I/O is still "enjoy" the effect of some cache.
Is there a thorough way to close the effect of system cache?
-
Aceofgods almost 13 years@tom_cat: You need a kernel newer than 2.6.16, and Ubuntu 10.04 came with 2.6.32 if I am not mistaken, so this should work. I've just checked my 11.04 install for what it's worth, which does have this proc entry (unluckily no 10.04 here any more)
-
Aceofgods almost 13 years@Damon: Yeah,you are right. thanks so much. I have found that I had logged on a remote machine of older kernel.