I need to do it for more predictable benchmarking.
It is generally safe to delete it. You might want to close all graphical applications (e.g. banshee, rhythmbox, vlc, software-center, ..) to prevent any confusion of the programs accessing the cache (where did my file go all of a sudden!?).
The most common way you'll see on the web to check for free memory in Linux is by using the free command. Using the free -m command to check your Linux memory usage, displays the values as MB instead of KB. The free column beside -/+ buffers/cache with 823 MB is the actual free memory available to Linux.
Alternatively, right-click on the . cache folder itself with the mouse and select “Move to trash” to completely delete all cache files on your Linux PC.
Sounds like you want the sync command, or the sync() function.
If you want disk cache flushing: echo 3 | sudo tee /proc/sys/vm/drop_caches
You can do it like this:
# sync # (move data, modified through FS -> HDD cache) + flush HDD cache # echo 3 > /proc/sys/vm/drop_caches # (slab + pagecache) -> HDD (https://www.kernel.org/doc/Documentation/sysctl/vm.txt) # blockdev --flushbufs /dev/sda # hdparm -F /dev/sda # NEXT COMMAND IS NOT FOR BENCHMARKING: # should be run before unplug, flushes everything possible guaranteed. # echo 1 > /sys/block/sdX/device/delete
You may use strace to see that these are three different syscalls
Also, it may be desirable to turn off HDD cache using hdparm, not sure what thing you benchmarking.
In any way, you cannot prevent HDD to cache last 64/32/16 MB of recently used data. In order to kill that cache, just write some amount of zeroes (and flush) + read some unrelated place from HDD. This is required since cache may be divided to read-part and write-part. After that you can benchmark HDD.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With