Skip to content

Instantly share code, notes, and snippets.

@Gen2ly
Created June 6, 2012 20:32
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 Gen2ly/2884577 to your computer and use it in GitHub Desktop.
Save Gen2ly/2884577 to your computer and use it in GitHub Desktop.
Free unused memory
#!/bin/bash
# Free unused memory
flush_mem () {
sudo sync
echo 3 | sudo tee /proc/sys/vm/drop_caches
}
echo -e "\nMemory usage before purge:\n" && free -m
flush_mem || exit && echo " Error purging memory"
echo -e "\nMemory usage after purge:\n" && free -m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment