Huge Space gains after restart.

jonparadise

macrumors member
Original poster
Nov 5, 2005
66
0
London, UK
I'm having one of those 'clear out' days so that I can get rid of alot of crap off my system before backing up to install Leopard.

One thing that puzzles me, hopefully one of you may be able to answer.

Whenever I restart my computer, I gain around 1.4GB of hard disk space.

This seems to be like an awful lot.

I could maybe understand if it was due to not being restarted for a long time, but I only did an 'Onyx' and restart 2 days ago!

Any theories would be appreciated.
 

R.Youden

macrumors 68020
Apr 1, 2005
2,091
40
Sometime applications will create small text files (like .plist files or .log files). Sometimes these files can get into a 'run-away' state and they just get bigger and bigger.

Try using WhatSize. This is great for finding out what is taking up all the space on your mac. If you have iLife installed and don't use Garageband or iDVD or iMovie then you can delete all the templates etc and you save loads of space.

Also try XSlimmer and Monolingual.

All great space saving apps!
 

xUKHCx

Administrator emeritus
Jan 15, 2006
12,587
6
The Kop
How much ram do you have. There s a fle called sleepimage or something similar that is approxnmately equal to the ammount of ram you have in your system, thsa gets cleaered after a restart. (Well on my system at least)
 

Deej

macrumors regular
Apr 25, 2005
133
7
UK
Does the useage creep back up again? It could be swapfile / virtual memory ...
 

R.Youden

macrumors 68020
Apr 1, 2005
2,091
40
How much ram do you have. There s a fle called sleepimage or something similar that is approxnmately equal to the ammount of ram you have in your system, thsa gets cleaered after a restart. (Well on my system at least)
WOW, didn't know about that!
 

xUKHCx

Administrator emeritus
Jan 15, 2006
12,587
6
The Kop
WOW, didn't know about that!
Can't remember if I cause this to happen by messing around with settings in terminal or if this is the default behaviour. It is found in /private/var/vm if you want to see its behavour on your system.
 

R.Youden

macrumors 68020
Apr 1, 2005
2,091
40
Can't remember if I cause this to happen by messing around with settings in terminal or if this is the default behaviour. It is found in /private/var/vm if you want to see its behavour on your system.
Bloody Hell!!

There are 4 swapfiles, totaling about 4GB, what is the easiest way to delete them and is it safe to do so?
 

sammich

macrumors 601
Sep 26, 2006
4,285
215
Sarcasmville.
I'm am pretty certain that it isn't a sleep image. The sleep image is reserved space on the main hard drive. If it is removed everytime you restart then what if you had say 2 gig of ram = 2gig for sleep image, you use some of that space, and you now have less than 2 gigs on hdd free? Then you put the laptop to sleep? Then what?

No, the space you are 'getting back' is simply the swap space that has been used by the system after you ran out of ram (swap memory is stored on the hard drive, that is when when you run out of ram, your computer will slow down and you will hear the hard drive 'seek' very often). I usually have parallels running and my swap space reaches 1.5gigs fairly often. Restarting gets rid of it, and you start at 64 megs of swap space, reclaiming the 1.4375gigs.
 

Deej

macrumors regular
Apr 25, 2005
133
7
UK
Bloody Hell!!

There are 4 swapfiles, totaling about 4GB, what is the easiest way to delete them and is it safe to do so?
This is what I have in that directory

-rw------T 1 root wheel 2G Oct 24 12:47 sleepimage
-rw------T 1 root wheel 64M Oct 11 19:08 swapfile0
-rw------T 1 root wheel 64M Oct 12 11:19 swapfile1
-rw------T 1 root wheel 128M Oct 17 15:43 swapfile2
-rw------T 1 root wheel 256M Oct 17 15:44 swapfile3
-rw------T 1 root wheel 512M Oct 17 15:57 swapfile4


This is on a Macbook with 2Gb Ram (which would tie in quite nicely with the sleepimage file :D )
 

sanford

macrumors 65816
Jan 5, 2003
1,265
0
Dallas, USA
I'm am pretty certain that it isn't a sleep image. The sleep image is reserved space on the main hard drive. If it is removed everytime you restart then what if you had say 2 gig of ram = 2gig for sleep image, you use some of that space, and you now have less than 2 gigs on hdd free? Then you put the laptop to sleep? Then what?

No, the space you are 'getting back' is simply the swap space that has been used by the system after you ran out of ram (swap memory is stored on the hard drive, that is when when you run out of ram, your computer will slow down and you will hear the hard drive 'seek' very often). I usually have parallels running and my swap space reaches 1.5gigs fairly often. Restarting gets rid of it, and you start at 64 megs of swap space, reclaiming the 1.4375gigs.
Sleep image doesn't seem to be reserved until you sleep the first time. So run, sleep, lose space to sleep, reboot, regain space until you sleep again.

Oh, and on a UNIX system swaps gets reserved along the way, not necessarily only if you run out of RAM. Some systems keep a swap = to total system memory reserved even if never get near max RAM usage.
 

sanford

macrumors 65816
Jan 5, 2003
1,265
0
Dallas, USA
Bloody Hell!!

There are 4 swapfiles, totaling about 4GB, what is the easiest way to delete them and is it safe to do so?
Restarting should erase your swaps as it's part of the shut down process. It's typically safe to just delete them; if they are in active use, the OS won't let you empty them from the trash, and if they're not active it will just recreate then ones it needs. But YMMV. And they're just going to come back.
 

sammich

macrumors 601
Sep 26, 2006
4,285
215
Sarcasmville.
Bloody Hell!!

There are 4 swapfiles, totaling about 4GB, what is the easiest way to delete them and is it safe to do so?
Deleting the swapfiles is akin to taking a stick of ram out of your computer whilst it is running.

The only way to rid yourself of these swapfiles is either do a restart, get more ram (usually involves a restart:eek:), or if you manage to free up a lot of memory by closing apps that hog ram, the swapfiles will eventually (it takes some random, very long time) shrink away. Perhaps apple will have fixed this in leopard, more active purging of swapfiles back to ram?
 

sanford

macrumors 65816
Jan 5, 2003
1,265
0
Dallas, USA
Deleting the swapfiles is akin to taking a stick of ram out of your computer whilst it is running.

The only way to rid yourself of these swapfiles is either do a restart, get more ram (usually involves a restart:eek:), or if you manage to free up a lot of memory by closing apps that hog ram, the swapfiles will eventually (it takes some random, very long time) shrink away. Perhaps apple will have fixed this in leopard, more active purging of swapfiles back to ram?
See above: if they're in use, i.e. the active swaps, when you try to empty the trash, the OS won't let you. It's pretty fail-safe. Revise your analogy to: trying to yanking a stick of RAM stuck in the slot out of your computer while it's running. And it's stuck but good.
 

Deej

macrumors regular
Apr 25, 2005
133
7
UK
This is what I have in that directory

-rw------T 1 root wheel 2G Oct 24 12:47 sleepimage
-rw------T 1 root wheel 64M Oct 11 19:08 swapfile0
-rw------T 1 root wheel 64M Oct 12 11:19 swapfile1
-rw------T 1 root wheel 128M Oct 17 15:43 swapfile2
-rw------T 1 root wheel 256M Oct 17 15:44 swapfile3
-rw------T 1 root wheel 512M Oct 17 15:57 swapfile4


This is on a Macbook with 2Gb Ram (which would tie in quite nicely with the sleepimage file :D )
Just to further this experiment, I've just rebooted, and this is what I have now :)


-rw------T 1 root wheel 2G Oct 24 12:47 sleepimage
-rw------T 1 root wheel 64M Oct 24 13:18 swapfile0


Hope that helps.
 

sammich

macrumors 601
Sep 26, 2006
4,285
215
Sarcasmville.
Sleep image doesn't seem to be reserved until you sleep the first time. So run, sleep, lose space to sleep, reboot, regain space until you sleep again.

Oh, and on a UNIX system swaps gets reserved along the way, not necessarily only if you run out of RAM. Some systems keep a swap = to total system memory reserved even if never get near max RAM usage.
Nope. The sleep image seems to be reserved the instant you boot up the system for the first time (like right after a full install of the OS). Why? I installed Tiger on an external hdd, did not put it to sleep, and found a sleep image in the /var/vm folder.

More convincingly, why is my sleepimage older than my uptime on my computer?
 

sanford

macrumors 65816
Jan 5, 2003
1,265
0
Dallas, USA
Nope. The sleep image seems to be reserved the instant you boot up the system for the first time (like right after a full install of the OS). Why? I installed Tiger on an external hdd, did not put it to sleep, and found a sleep image in the /var/vm folder.

More convincingly, why is my sleepimage older than my uptime on my computer?
Testing...
 

sammich

macrumors 601
Sep 26, 2006
4,285
215
Sarcasmville.
See above: if they're in use, i.e. the active swaps, when you try to empty the trash, the OS won't let you. It's pretty fail-safe. Revise your analogy to: trying to yanking a stick of RAM stuck in the slot out of your computer while it's running. And it's stuck but good.
If you're digging around hidden directories on your computer using terminal (ls -l) i'm sure they have heard of sudo bash. There are many ways to skin a cat (sorry:D), especially from the terminal.
 

sanford

macrumors 65816
Jan 5, 2003
1,265
0
Dallas, USA
If you're digging around hidden directories on your computer using terminal (ls -l) i'm sure they have heard of sudo bash. There are many ways to skin a cat (sorry:D), especially from the terminal.
Well, now, yeah on that point, to poster above (not sammich): stay the heck out of Terminal! I figured he was using something like WhatSize? and noticed the swaps.

And as for the sleep image: you are correct, brother, created on boot. Along with a brand new 64MB swap (I have a 2GB system). Also for poster above, and not you, sammich: you can't get rid of all your swaps; (most?) UNIX systems require at least a little tiny swap, period, ergo the 64MB swap created when I boot my 2GB system. I wouldn't mess with your swaps. They're there for a reason, and they're just going to come back, anyway as the OS sees fit. Now sometimes you can get 4GB log files because of randomness, they don't for some reason clear on restart, or because you never have your Mac on and awake at the right time -- usually in the middle of the night -- for the automated system clean-up jobs to run. Logs you can safely delete. The OS will just create new ones.
 

sammich

macrumors 601
Sep 26, 2006
4,285
215
Sarcasmville.
What's wrong with Terminal? I use it all the time! :)
I use scissors all the time too! :p

Now, just out of curiosity, I'm going to delete a swapfile.*

Later...
Okay, my curiosity is satisfied. But deleting swapfiles doesn't seem to have an immediate effect. I ran everything, iphoto, pages, numbers, keynote, parallels (booted in to winxp), itunes, photoshop, safari and it racked up 1gig in swapfiles. I deleted them, then what? Nothing happened, just like normal.

The only way I can explain this is that, deleting the swapfiles is okay as long as they aren't overwritten by the system (don't count on it). The OS still has the pointer to the location of the swapfile on the hdd, so it can access it like it is still visible. I haven't restarted or anything.

Menumeters screenshot, look down the bottom.
 

Attachments

jonparadise

macrumors member
Original poster
Nov 5, 2005
66
0
London, UK
Gosh, thanks for the replies guys.

So it sounds like it's just the system doing it's thing and nothing sinister.

I've got 2 GB Ram.
 

dr_lha

macrumors 68000
Oct 8, 2003
1,587
0
What's wrong with Terminal? I use it all the time! :)
Only people who know how the Terminal works, should use it. People who ask questions like "Can I just delete these swap files", most likely don't fit into that category! :D
 

Deej

macrumors regular
Apr 25, 2005
133
7
UK
Only people who know how the Terminal works, should use it. People who ask questions like "Can I just delete these swap files", most likely don't fit into that category! :D
Heh - true enough!! :D

Of course even if they *do* use Terminal, only the "REAL MEN" use vi ;) :D
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.