Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Automatically reclaim memory from leaky programs' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically reclaim memory from leaky programs
Authored by: Yoyo22 on Jan 14, '13 05:04:26AM

Using perl, this is rather easy... add the following to your cron setup ('crontab -e' using terminal):

5,15,25,35,45,55 * * * * top -l 1 | perl -ne 'if($_ =~ m/.*?(\d+)M inactive.*/){if($1 > 800 ) {$g="/usr/local/bin/growlnotify -mPurge:$1"; `$g`;`purge`}}'

the above activates every 10 minutes and if inactive memory is greater than 800MB it runs purge (plus growlnotify message in relation)... this seems to help on an older 2007 macbook pro with 6GB ram (and very much so in specific usage situations, that do not fit the tuned algorithm). It also includes an easy way to get growlnotify to work in conjunction with perl oneliners.



[ Reply to This | # ]