Skip to content

Instantly share code, notes, and snippets.

@ekinertac
Created February 12, 2013 12:36
Show Gist options
  • Save ekinertac/4762052 to your computer and use it in GitHub Desktop.
Save ekinertac/4762052 to your computer and use it in GitHub Desktop.
Linux systems has no `purge` command lie Mac OSX. So i did this
#!/bin/bash
# Free unused memory
flush_mem () {
sync
echo 3 | 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