Skip to content

Instantly share code, notes, and snippets.

@kikaigyo
Created September 27, 2012 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kikaigyo/3796683 to your computer and use it in GitHub Desktop.
Save kikaigyo/3796683 to your computer and use it in GitHub Desktop.
リミッターつきpurge.
#!/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 "Testing status of inactive free memory..."
if [ "$MM" -gt "$msize" ]; then
echo "You have too much inactive free memory. ${MM}MB Releasing now..."
purge
else
echo "Memory amount ${MM}MB does not meet purge threshold."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment