Clear Memory Cache in Linux: drop_caches Explained

Last updated: 30 October 2026

Linux uses spare memory for the page cache and other caches, so "free" memory looks low even on a healthy server. That memory is released automatically when programs need it. You can drop the cache by hand, but the kernel documentation says it can cause performance problems and should be used for testing or debugging, not as a scheduled job.

Quick answer
  • Check first: read the "available" column in free -h, not "free".
  • One-off drop (testing only): sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
  • Do not run this hourly from cron on a production server.

In this guide

Read memory correctly

free -h

Look at the available column. It estimates how much memory programs can use without swapping, counting cache that can be reclaimed. A small "free" value with a large "available" value is normal.

Drop caches manually

This is non-destructive. Run sync first so dirty data is written to disk:

sync
echo 3 | sudo tee /proc/sys/vm/drop_caches

The kernel may log a line such as drop_caches: 3. The kernel documentation says these messages are informational and do not mean anything is wrong. After dropping, the system must read data from disk again, so the next requests can be slower.

What the values mean

ValueReleases
1Page cache
2Reclaimable slab objects (dentries and inodes)
3Both page cache and slab objects

If memory is really short

  • Check which processes use memory: ps aux --sort=-%mem | head.
  • Look at swap use with free -h and vmstat 1. Constant swapping means a real shortage.
  • Add RAM, reduce service memory limits (PHP workers, database buffers), or move services off the server.
  • Check for memory leaks in long-running processes and restart them on a schedule if needed.

FAQ

Is it safe to clear the cache?

Yes, it does not destroy data, but it can slow the server while caches rebuild.

Why is my free memory always low?

Linux fills spare RAM with cache on purpose. It is released when needed.

Should I put it in cron?

No. The kernel documentation advises against using this outside testing or debugging.

Sources

More on this site: Security guides · All IT guides

Comments