Code/new purgeVM: Difference between revisions

From kJams Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
(If what I am writing seems unintelligible to you, it might be best for you not to attempt it!)
(If what I am writing seems unintelligible to you, it might be best for you not to attempt it!)


<pre?
<pre>
sudo purge
sudo purge
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
Line 22: Line 22:
and add your standard user account info like this:
and add your standard user account info like this:


 
<pre>
# User privilege specification
# User privilege specification
root    ALL=(ALL) ALL
root    ALL=(ALL) ALL
%admin  ALL=(ALL) ALL
%admin  ALL=(ALL) ALL
yourshortusername    All=(ALL) ALL
yourshortusername    All=(ALL) ALL
 
</pre>
Alternately, you can run AppleScript Editor, and paste the following code into a new script:
Alternately, you can run AppleScript Editor, and paste the following code into a new script:
 
<pre>
do shell script "sudo purge
do shell script "sudo purge
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
Line 35: Line 35:
sudo launchctl load -wF /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
sudo launchctl load -wF /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
" with administrator privileges
" with administrator privileges
 
<pre>
Save as an application by selecting "Save…" from the File menu then selecting "Application" from the "File format" pop up menu.
Save as an application by selecting "Save…" from the File menu then selecting "Application" from the "File format" pop up menu.


Now you can just double click and run like any normal OSX app.
Now you can just double click and run like any normal OSX app.

Revision as of 00:30, 3 December 2013

If you are having problems with losing disk space on OSX due to swap file space growing out of control, you can solve the issue by rebooting Alternately, if you are not afraid of venturing into Terminal land, you can use this tiny little app I wrote, which will purge unused RAM cache and collapse and remove unused swap space, potentially dramatically restarting "missing" disk space and restoring system performance.

Be VERY careful, however, as setting it up involves doing things that could potentially render your system unbootable. (If what I am writing seems unintelligible to you, it might be best for you not to attempt it!)

sudo purge
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
sudo rm /private/var/vm/swapfile*
sudo launchctl load -wF /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist

Open a text editor and paste in the code. Save somewhere. Then go to Terminal. Log in to an administrator account and type "chmod 755 path/to/the/file". Now you can double click on it, and it will open Terminal, run the code, and exit. You need to make sure you are either running this from an admin account, or add your standard user account to sudoers for this to work.

To add your standard account to sudoers, log in to an admin account, type "sudo visudo" and type in your admin password. Find the following line:

  1. User privilege specification

root ALL=(ALL) ALL %admin ALL=(ALL) ALL

and add your standard user account info like this:

# User privilege specification
root    ALL=(ALL) ALL
%admin  ALL=(ALL) ALL
yourshortusername     All=(ALL) ALL

Alternately, you can run AppleScript Editor, and paste the following code into a new script:

do shell script "sudo purge
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
sudo rm /private/var/vm/swapfile*
sudo launchctl load -wF /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
" with administrator privileges
Save as an application by selecting "Save…" from the File menu then selecting "Application" from the "File format" pop up menu.

Now you can just double click and run like any normal OSX app.