Skip to content

Instantly share code, notes, and snippets.

@vishaltelangre
Created November 7, 2013 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vishaltelangre/7350043 to your computer and use it in GitHub Desktop.
Save vishaltelangre/7350043 to your computer and use it in GitHub Desktop.
Free up unused memory [ubuntu]
#!/bin/bash
#
# Release memory used by the Linux kernel on caches.
free -m
sudo sysctl -w vm.drop_caches=3
sleep 5
sync && echo 3 > sudo /proc/sys/vm/drop_caches
free -m
# 1 -> to free pagecache
# 2 -> to free dentries and inodes
# 3 -> to free pagecache, dentries and inodes
#
# Reference: http://www.commandlinefu.com/commands/view/2888/release-memory-used-by-the-linux-kernel-on-caches
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment