Created
December 19, 2012 22:38
-
-
Save rad3ks/4341204 to your computer and use it in GitHub Desktop.
Simple script for Mac users who feel lack of free memory. Script automatically purges memory every 10 minutes, if there is less than 20 MB free.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Purging memory if there is less than 20 MB free. | |
# Author: Radosław Szeja | |
# Date: 9.12.2012 | |
while true; do | |
fm=`top -l 1 | awk '/PhysMem/ {print $10}' | sed -e 's/\([0-9]*\)\(M\)/\1/g'`; | |
if [ $fm -lt '20' ];then | |
`purge`; | |
free_mem=`top -l 1 | awk '/PhysMem/ {print $10}' | sed -e 's/\([0-9]*\)\(M\)/\1/g'`; | |
let sum=$free_mem-$fm | |
echo "${sum}M of memory has been purged."; | |
fi | |
sleep 10*60; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment