Skip to content
TURNKEYGNU / LINUX
AppsDocumentationBlogScreenshotsGitHubTurnKey Hub
Home/Blog/Invalidating the disk cache on Linux

From the project

Invalidating the disk cache on Linux

By Liraz Siri4 May 20151 min read
developmenttips

Here's a super easy way to invalidate the disk cache, which is useful for testing IO performance in the real world, where you can't rely on all of your reads being served up from a super-fast RAM cache rather than a vastly slower physical disk drive.

This will free up everything in the disk cache:

echo 3 > /proc/sys/vm/drop_caches

Or if you want more control over exactly what is being freed...

  1. This frees up the pagecache (e.g., cache of contents of files):

    echo 1 > /proc/sys/vm/drop_caches
    
  2. This frees up dentries and inodes:

    echo 2 > /proc/sys/vm/drop_caches
    

    In a nutshell, Dentries are directory structures in memory. Inodes are the headers of files in memory. Inodes have links to page blocks, which is where the actual file data is stored.

Keep in mind you need root privileges to do this.

Keep exploring

Find your next server

Browse ready-to-use appliances by the job you need to do.

Explore the app library
TURNKEYGNU / LINUX

Own your infrastructure without starting from scratch.

Explore TurnKey
AboutDocumentationFAQBlogGitHub
Free and open sourceSecure by defaultReady to deploy