1
I run the following to clear cached files from the filesystem/system memory:
# echo 3 > /proc/sys/vm/drop_caches
I'd like to do this on a scripted basis, so that when I do I/O testing to compare the speed of (say) two different binaries, I ensure that the particular state of the file system (and whether files being accessed are cached) minimizes any variance in speed test results.
My question is: How long does it take for the above command to do its magic? I'd like to know if I need to add some kind of programmatic pause after running the above, to help better establish the baseline I'm after.
Is the clearing effect immediate, and if not, is any delay measurable?
You can see the effect in real time, by running
htop
and watching its memory usage meter. (Optionally, also add another copy of the same meter in "text" mode, so that it would show both a graphical meter and the actual numbers.) After the command, "cached" memory should drop to zero immediately. – user1686 – 2014-06-04T19:07:36.903