All Products
Search
Document Center

Alibaba Cloud Linux:Call the drop_caches interface to clear the page cache

Last Updated:Feb 27, 2026

When a Linux operating system and user processes in the operating system run, the page cache (also known as file cache) is utilized. The page cache usage increases over the runtime, which leads to high system resource consumption. This may cause performance jitter for performance-sensitive business or even cause out-of-memory (OOM) errors to occur in specific tasks. In business scenarios in which you must release a large amount of memory, you can call the /proc/sys/vm/drop_caches interface to release the page cache.

Procedure

Warning

Memory reclamation by calling the drop_caches interface deletes page cache and the required dentries and inodes from the system, which may cause performance degradation during disk I/O operations. The kernel must re-read this data from disk on the next access, which can cause significant I/O and CPU overhead, especially for data under heavy use. Exercise caution when you reclaim memory based on your business requirements.

The following operations release only clean (already written to disk) cached data. Dirty pages in memory are not released until they are written to disk. To release dirty pages from memory, run the sync command to write the dirty pages from memory to disk and then call the drop_caches interface to clear the page cache. This way, you can release more memory.

Cache regrows automatically after clearing. The kernel immediately begins caching data again as applications access files. Each drop_caches operation also produces an informational message in the kernel log (for example, sh (1234): drop_caches: 3). These messages are normal and do not indicate a problem.

ValueReleasesUse case
1Page cacheFree file data cache (most common)
2dentries and inodesFree filesystem metadata cache
3Page cache, dentries, and inodesFree all reclaimable cache
  • Release the page cache.

    • Call the drop_caches interface to release the page cache.

      sudo sh -c 'echo 1 > /proc/sys/vm/drop_caches'
    • Run the sysctl command to release the page cache.

      sudo sysctl -w vm.drop_caches=1
  • Release dentries and inodes.

    • Call the drop_caches interface to release dentries and inodes.

      sudo sh -c 'echo 2 > /proc/sys/vm/drop_caches'
    • Run the sysctl command to release dentries and inodes.

      sudo sysctl -w vm.drop_caches=2
  • Release the page cache, dentries, and inodes.

    • Call the drop_caches interface to release the page cache, dentries, and inodes.

      sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
    • Run the sysctl command to release the page cache, dentries, and inodes.

      sudo sysctl -w vm.drop_caches=3