Skip to content

Instantly share code, notes, and snippets.

@bugcy013
Forked from Gen2ly/purge-memory
Created September 14, 2013 17:53
Show Gist options
  • Select an option

  • Save bugcy013/6564076 to your computer and use it in GitHub Desktop.

Select an option

Save bugcy013/6564076 to your computer and use it in GitHub Desktop.
#!/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