TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Script to Release Inactive Memory on Mac OSX Lion

1 pointsby mark_ellulalmost 13 years 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.<p>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.<p>I cannot take credit for it, I found it here (http://hints.macworld.com/article.php?story=20120410153721860)<p>Without further ado, the script is below, copy it into a file and chmod +x it and run....<p>#!/bin/bash<p># 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.<p>msize=1200<p>VS=`vm_stat | awk '/Pages\ inactive\:/ {print $3}' | sed 's/\.//g'` MM=`echo "$VS/255" | bc`<p>echo "Testing status of inactive free memory..."<p>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 comment

lucian303almost 13 years ago
I think html chars are killing this script. Can you repost as code?