Skip to content

Instantly share code, notes, and snippets.

@kikaigyo
Created September 28, 2012 02:49
Show Gist options
  • Save kikaigyo/3797673 to your computer and use it in GitHub Desktop.
Save kikaigyo/3797673 to your computer and use it in GitHub Desktop.
purge_ja
#!/bin/bash
# This script checks the available inactive memory.
# Memory is purged if the available number of MB is
# greater than the following "msize" variable. Attach
# this script to launchd to run it periodically.
msize=1200
MM=`vm_stat | awk '/Pages\ inactive\:/ {print int($3/256)}'`
echo "非使用中のメモリサイズを計算しています..."
echo ""
if [ "$MM" -gt "$msize" ]; then
echo "現在${MM}MBのメモリが非使用領域として確保されています。設定値${msize}MBを超えたためpurgを実行します..."
echo""
purge
else
echo "現在非使用中のメモリは${MM}MBです。設定値${msize}MB以下のためpurgeはキャンセルされました。"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment