man drop_caches




NAME

  drop_caches - drop clean caches from memory (Linux 2.6.16+)


SYNOPSIS

  drop_caches [-nqpiogmkashv] [0|1|2|3]


DESCRIPTION

  The  drop_caches command can display values from /proc/meminfo and can write speci-
  fied value to /proc/sys/vm/drop_caches, valid values are:
    0 # default, does not sync or write
    1 # free pagecache
    2 # free dentries, inodes
    3 # free pagecache, dentries, inodes

  This is a Linux tunable added in 2.6.16 kernel.  See also "man 5 proc".  Writing to
  this  file causes the kernel to drop clean caches, dentries and inodes from memory,
  causing that memory to become free.  Writing the value frees  memory,  the  current
  value  in  the  file  is  not significant.  This is a non-destructive operation and
  dirty objects cannot be freed.   To  get  maximum  benefit,  prior  to  writing  to
  /proc/sys/vm/drop_caches this binary issues two sync() and sleep(1) operations.

  To  write to /proc/sys/vm/drop_caches requires root authority.  On systems where it
  is appropriate for users to do this, add the SUID bit to  the  binary.   Otherwise,
  issue command via sudo or as appropriate.  On large memory systems, if the cache is
  large it may take some time for memory to be dropped.


OPTIONS

  -n | --nosync
          Do   not    perform    sync()    operations    prior    to    writing    to
         /proc/sys/vm/drop_caches.

  -q | --quiet
          Do not write before and after MemFree values to stdout.

  -p | --pct
          Display free memory as percentage of total, too.

  -i | --info
          Write additional /proc/meminfo values to stderr.

  -o | --output
          Write additional /proc/meminfo values to stdout.

  -g | --giga
          Dispaly values in GigaBytes.

  -m | --mega
          Dispaly values in MegaBytes.

  -k | --kilo
          Dispaly values in KiloBytes.

  -a | --all
          Dispaly values in Giga, Mega, and KiloBytes.

  -s | --showhost
          Display hostname on info lines (useful when issued via mpirun).

  -v | --version
          Display program version and exit.


EXAMPLES

  Displaying current values without dropping caches:

   ognip: drop_caches -i
   #       Before:
   #     MemTotal:   126.040 GB
   #      MemFree:     0.250 GB
   #       Cached:   120.572 GB
   #       Active:     0.126 GB
   #     Inactive:   120.547 GB
   #        Dirty:     0.000 GB
   #       Mapped:     0.027 GB
   #         Slab:     5.058 GB
   MemFree:    0.250

  Dropping all caches:

   ognip: sudo ./drop_caches 3
   MemFree:    0.248  125.812

  Note, after dropping all caches free memory increased to 125GB.  This operation may
  take some time, from pacct records:

   ognip: uakpacct -c drop_caches -ea 15:39:30
   #End_Date/Time Start_hh:mm:ss Userid Command  Flg Exit  CPU
   #-------------       -------- ------ -------  --- ----  ---
   12/30 15:40:10       15:39:23 root   drop_cac 002    0 44.7s


NOTES

  The drop_caches program was written for deployment under Cray XT Compute Node Linux
  (CNL)  to  provide  a means to free all caches prior to starting a new application.
  It was subsequently enhanced as it proved useful for IO benchmarks and is now being
  used in health checks in job epilogues.

  For Linux systems, one can drop caches via:
   # sudo sync; sudo ksh -c "echo 3>/proc/sys/vm/drop_caches"

  The drop_caches binary combines the sync (issued twice) and displays the results.


ACKNOWLEDGEMENTS

  Written  at  the  University  of Alaska Arctic Region Supercomputing Center (ARSC).
  Ongoing maintenance via SourceForge by Denali Sun Consulting.

  Suggestions or bug reports can be directed to denalisun907@gmail.com.


RELATED INFORMATION

  proc(5), sync(2).