So I've got a 13" Macbook Air with 128GB, and recently I got a message showing that I'm running out of space, so I did a quick check to see what was taking up all of space, and I found out that I have 4GB of sleep image (which is normal), but 20 swap files, each taking up from 60mb to 1gb. With a small disk size, this is really unacceptable so I was wondering if it was safe to delete some of the swap files and let the system build them up. Or would a restart help (Though I'd prefer not, had a bet with my friend to keep my uptime as long as possible :p) Any suggestions appreciated.
You can disable Hibernate to regain your size in RAM on your SSD/HD: First disable it:
Then free up space:
... if you want to enable it again:
Note: -a means on charger and on battery, -b means battery and -c means with charger.
Alternatively if you have more than one disk you can symlink sleepimage to an HD so it can physically locate there.
First disable Swap:
Later delete the files:
... if you want to enable it again do:
A restart will definitively solve the issue.
Even if you kill the offending process, the system won't clear up the swap files - you need a reboot to do that.
Also, deleting the swap files would be a bad idea. You would need to sudo to do it, and if the system has the file open, even if you rm the file, it'll still be kept around as the file handle would be open, so you wouldn't gain the space back.
By all means try it, but it's not recommended :)
You can delete the sleepimage without damaging anything. The system will recreate it over time. Usually when I get a message that I'm running out of space I just go to the terminal and type
To finish answering your question, and to let you know why you should trust me, you can delete every file in
Basically, you'll always have VM files with size roughly equivalent to the amount of RAM you have used running programs. You can delete these and upon the next significant background activity event, the computer may re-create them. If you only have one program running, and doing nothing, but have huge VM files, that may be a sign of a memory leak in a program, but I have noticed that a lot of the preference panels and plugins on the menu bar are really huge memory hogs: If you run the Google Drive Synchronizer thing and the Dropbox app and the box.com app then those will call home 24/7 and move files around non-stop. They are more than enough activity to generate legitimate and huge VM profiles.
Hope that helps!