Hacker News new | ask | show | jobs
Script to Release Inactive Memory on Mac OSX Lion
1 points by mark_ellul 5118 days ago
Hi, Last year I bought a 27" iMac with 8 Gig of memory with Lion. The machine is fantastic but Lions memory management has alot to be desired, it would totally stall when the inactive memory was about 3 Gig and the Free Memory around 50 Meg, and running purge would release some memory but less than an hour later I was in the same position.

In my investigations I have finally found a script which clears the inactive memory down from over 1.2 Gig down to about 90 Meg.

I cannot take credit for it, I found it here (http://hints.macworld.com/article.php?story=20120410153721860)

Without further ado, the script is below, copy it into a file and chmod +x it and run....

#!/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

VS=`vm_stat | awk '/Pages\ inactive\:/ {print $3}' | sed 's/\.//g'` MM=`echo "$VS/255" | bc`

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 exit 0 else echo "Memory amount" $MM"MB does not meet purge threshold." exit 0 fi

1 comments

I think html chars are killing this script. Can you repost as code?