What is the purpose of /proc/sys/vm/drop_caches in Red Hat Enterprise Linux?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux

Issue

  • What's the purpose of /proc/sys/vm/drop_caches in Red Hat Enterprise Linux?
  • How to release cache memory using /proc/sys/vm/drop_caches?
  • New process cannot be started due to insufficient free memory, how to free additional memory?
  • Inactive memory not being released, how to free memory?

Resolution

Background

Commands

  • Optional : Start with the sync command to have the kernel write as many dirty cache pages to disk as it can (to maximize the number of data cache pages that can be dropped).

  • Trigger cache-dropping by using sysctl -w vm.drop_caches=<number> or by writing directly to /proc/sys/vm/drop_caches as follows:

    • Free pagecache, dentries and inodes

      echo 3 >/proc/sys/vm/drop_caches
      
    • Free dentries and inodes only

      echo 2 >/proc/sys/vm/drop_caches
      
    • Free the pagecache only

      echo 1 >/proc/sys/vm/drop_caches
      
SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.