Emptying buffers cache and swap

Emptying the buffers cache

You can signal the Linux Kernel to drop various aspects of cached items by changing the numeric argument to the above command.
  • To free pagecache:
    # echo 1 > /proc/sys/vm/drop_caches
    
  • To free dentries and inodes:
    # echo 2 > /proc/sys/vm/drop_caches
    
  • To free pagecache, dentries and inodes:
    # echo 3 > /proc/sys/vm/drop_caches

Swap

If you want to clear out your swap you can use the following commands.
$ free
             total       used       free     shared    buffers     cached
Mem:       7987492    7298164     689328          0      30416     457936
-/+ buffers/cache:    6809812    1177680
Swap:      5963772     609452    5354320
Then use this command to disable swap:
$ swapoff -a
You can confirm that it's now empty:
$ free
             total       used       free     shared    buffers     cached
Mem:       7987492    7777912     209580          0      39332     489864
-/+ buffers/cache:    7248716     738776
Swap:            0          0          0
And to re-enable it:
$ swapon -a
And now reconfirm with free:
$ free
             total       used       free     shared    buffers     cached
Mem:       7987492    7785572     201920          0      41556     491508
-/+ buffers/cache:    7252508     734984
Swap:      5963772          0    5963772

Comments

Popular posts from this blog

HAproxy logging

teamcity Automatic Agent Start under Linux

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all