What is /proc/sys/vm/drop_caches?

🔍 What is /proc/sys/vm/drop_caches?

This is a virtual kernel interface that lets you manually free up memory used by:

  • The page cache (file data)

  • Dentries (directory entries)

  • Inodes (metadata for files)

It’s useful when:

  • You want to test performance without file cache interference

  • You need to free up RAM quickly in a controlled environment

  • You're benchmarking or tuning systems and want a clean cache state


⚠️ Why cat drop_caches gives "Permission denied"

root@iamsonukushwaha:/proc/sys/vm# cat drop_caches cat: drop_caches: Permission denied

Even as root, you can't read this file.

Here's why:

--w-------. 1 root root 0 Oct 6 15:48 drop_caches
  • It’s write-only.

  • There’s no read (r) permission — by design.

  • The kernel doesn't expose a value here; it only accepts commands.


✅ How to properly clear caches

Before you drop caches, it’s important to sync your file system to avoid data loss:

sync

Then, choose the appropriate option:

# 1: Clear page cache echo 1 > /proc/sys/vm/drop_caches # 2: Clear dentries and inodes echo 2 > /proc/sys/vm/drop_caches # 3: Clear page cache, dentries, and inodes echo 3 > /proc/sys/vm/drop_caches

✅ Recommended safe combo:

sync && echo 3 > /proc/sys/vm/drop_caches

Popular posts from this blog

Tarana - Music Player