Operations 5 min read

How to Safely Release Linux Cache Memory with /proc/sys/vm/drop_caches

This guide explains why Linux cache memory isn’t automatically freed, when manual cache dropping is appropriate, and how to safely release page cache, reclaimable slab objects, or both using the /proc/sys/vm/drop_caches interface, including practical command examples.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
How to Safely Release Linux Cache Memory with /proc/sys/vm/drop_caches

Cache memory is used by the kernel to speed up operations and reduce disk I/O; it can be reclaimed when needed, but it is not automatically freed after a program exits, which may lead to low available physical memory after heavy file I/O.

Generally, manually dropping caches is discouraged unless you have a specific need, such as testing cache usage, because the cached pages are still usable for the same application.

Releasing cache contents

You can free cache memory by writing to the system control file /proc/sys/vm/drop_caches.

1. Release page cache: echo 1 > /proc/sys/vm/drop_caches 2. Release reclaimable slab objects (including dentries and inodes): echo 2 > /proc/sys/vm/drop_caches 3. Release both slab objects and page cache: echo 3 > /proc/sys/vm/drop_caches This operation is non‑destructive and does not free any dirty objects. To increase the amount of data that can be dropped, run sync before writing to /proc/sys/vm/drop_caches, which flushes dirty pages to disk.

Note that /proc/sys/vm/drop_caches is not a mechanism for controlling the growth of kernel caches; the kernel automatically reclaims these objects when memory is needed elsewhere.

Using this file can cause performance problems because the removed cache objects must be recreated, consuming I/O and CPU, especially for heavily used data, so it is not recommended outside of testing or debugging environments.

Practical test

# free -m
              total        used        free      shared  buff/cache   available
Mem:           7794        2373        1478         431        3942        4691
Swap:          3967           0        3967
# echo 1 > /proc/sys/vm/drop_caches
# free -m
              total        used        free      shared  buff/cache   available
Mem:           7794        2373        2600         431        2821        4705
Swap:          3967           0        3967
# echo 2 > /proc/sys/vm/drop_caches
# free -m
              total        used        free      shared  buff/cache   available
Mem:           7794        1635        5527         431         631        5495
Swap:          3967           0        3967
# echo 3 > /proc/sys/vm/drop_caches
# free -m
              total        used        free      shared  buff/cache   available
Mem:           7794        1635        5529         431         630        5496
Swap:          3967           0        3967
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CacheMemory ManagementLinuxSystem Administration
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.