Skip to content

Instantly share code, notes, and snippets.

@monodeep12
Forked from vishaltelangre/freeme
Created February 17, 2016 03:28
Show Gist options
  • Save monodeep12/407c38c10ba9eae3bc8a to your computer and use it in GitHub Desktop.
Save monodeep12/407c38c10ba9eae3bc8a 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