Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.3: Use Secure Empty Trash to reclaim hard disk space' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Use Secure Empty Trash to reclaim hard disk space
Authored by: makern on Dec 15, '03 01:04:43PM

I am also experiencing the slow loss of space. I tracked it down to virtual memory & swap files. It seems that Panther handles virtual memory differently than Jaguar and doesn't handle it very well. If you look in /private/var/vm/ you might notice multiple swap files.
This morning I got a warning that I was running out of room on my System partition (only 130MB left; usually about 1.7GB). I checked the vm directory & found 6 swap files: 64MB, 64MB, 128MB, 256MB, 512MB & 512MB.
There are a few threads in some forums about this issue. Doesn't seem to be any way to get rid of them except for restarting.



[ Reply to This | # ]
10.3: Slightly easier (or more effective) way...
Authored by: srobart on Dec 15, '03 03:28:27PM

The easiest way I've found to delete the nasty swap files is to go into the terminal, su to root and type in "rm -rf /private/var/vm/*" (without the " obviously).
I've regained more than a gigabyte of space on my HD by doing that, unfortunately, it must be done every time your computer makes a new swap file. I just leave a terminal window open with the command in the window and hit the up key to recall the command, then hit enter.



[ Reply to This | # ]
10.3: Slightly easier (or more effective) way...
Authored by: babbage on Dec 15, '03 05:02:54PM

Uhh, don't do that. Just don't do that. You're deleting the memory contents of currently running programs. Those vm files aren't just debris, they actively represent data your system is trying to keep track of.

If you want to restrict the growth of VM usage, avoid running many programs simultaneously. If you can do so, try to keep a few GB of disc free so that swap consumption can grow naturally. Or if you want to spend some money, bulk up on RAM &/or get a bigger hard drive. Any of these will help with swap & disc space issues.

The details of Panther handles virtual memory may be different from how it was done in Jaguar & earlier, but the general idea isn't any different from how it has always been: if you are trying to have the system keep track of more data than you have physical memory, it will start swapping data out to swap files. If you have a lot of ram, the ceiling is higher before you start having to swap. If you have a lot of free disc space, you have a more comfortable buffer before problems start coming up.

But if you just start nuking swap files willy nilly, you're just begging for things to start going wrong. Please don't recommend that people do this, it's the wrong way to solve the problem.

(Alternatively, it would be nice if Apple had a utility -- preferably an automatic one -- that tried to reduce the growth of the VM size. This may be something that can be figured out by examining the open source Darwin core, but I've never looked into it. I'd assume that they already do some things to manage VM, but maybe other tools would be useful. However, it is very safe to say that sudo rm /var/vm/* is not a responsible or productive way to go about this.

---
--
DO NOT LEAVE IT IS NOT REAL

[ Reply to This | # ]

10.3: Slightly easier (or more effective) way...
Authored by: ajoakland on Dec 15, '03 11:28:39PM

Actually, this is probably NOT a problem, because, in unix, once a file is open, and it is being accessed, you really don't delete it or free it up until it is closed by the program using it. This is a common unix problem with trying to delete evergrowing log files. Even when you rm the file, you don't regain space until the programing using it closes it. Now I am assuming that a VM file would not be closed until the OS was done with it. Also the fact that the user who did this continued being able to work with no problems, adds some credence to the contents not really being lost.



[ Reply to This | # ]
Trashing swap can have deleterious effects.
Authored by: macmath on Dec 16, '03 03:05:31PM

I was trying out some utility which offered to trash swap. I incorrectly assumed that it would not trash something in use, and let it do so. But it trashed all the swapfiles anyway. The computer locked-up after a bit. The swapfiles should not be trashed by the user. Panther will give back swapfiles itself sometimes, however.



[ Reply to This | # ]
10.3: Use Secure Empty Trash to reclaim hard disk space
Authored by: SOX on Dec 15, '03 05:18:51PM

This is interesting. note the dates on the swap files:
drwx--x--x 10 root wheel 340 10 Dec 20:17 app_profile
-rw------T 1 root wheel 67108864 10 Dec 18:17 swapfile0
-rw------T 1 root wheel 67108864 10 Dec 19:43 swapfile1
-rw------T 1 root wheel 134217728 13 Dec 16:36 swapfile2
-rw------T 1 root wheel 268435456 14 Dec 14:37 swapfile3

I wonder what the heck is going on. Seems like I should be able to kill a 3 day old swap file.



[ Reply to This | # ]
10.3: Use Secure Empty Trash to reclaim hard disk space
Authored by: the1truestripes on Dec 16, '03 09:34:17AM
I wonder what the heck is going on. Seems like I should be able to kill a 3 day old swap file.

Depends, have you been running a program for three days? If so it may have "stuff" in there. Even if you havn't it might still be in use. The swap file may have been created three days ago when you were running Word, and then you started Excel two days ago and is put some more stuff in there, then you quit Word, and yesterday you started TextEdit and it used the same swap file, and then you quit Excel, but your three day old swap file still has parts in use by the TextEdit you just started recently...

If it is like any other Unix system I have used though the free space in the swap file will get used for other stuff that needs to swap. Also removing the files won't normally do any harm (a secure delete of them might, but a normal rm or drag to trash and "empty trash" won't) because as others have said Unix doesn't actually delete stuff until the last "reference" to it goes away (it will delete the name from the filesystem, but the contents live on until no process has the file open...and there is some interaction with hard links you probbably don't want to know about).

[ Reply to This | # ]

Later swapfiles have earlier dates?
Authored by: macmath on Dec 16, '03 03:26:24PM

What I find most interesting about the swapfiles in the above post is that later swapfiles have earlier dates. Why is swapfile3 dated before any of the others (unless SOX had successfully deleted swapfile0, swapfile1, swapfile 2 ealier AND the swapfiles which were created thereafter started with swapfile0 again) and why swapfile2 is dated before swapfile0 and swapfile1 (unless that above happened and SOX had successfully deleted the new swapfile0 and swapfile1 again).

SOX, if indeed you did delete these swapfiles without reprocussions, and if the next swapfile created after swapfile0-2 were deleted was called swapfile0, what was the size of the new swapfile0? 64 MB like the original swapfile0 or 512 MB like the swapfile4 would have been had the earlier swapfiles not been deleted.



[ Reply to This | # ]
Later swapfiles have earlier dates?
Authored by: macmath on Dec 16, '03 06:39:08PM

Doh! I guess I can tell from your post that the new swapfile0 and swapfile1 were both 64 MB again! ...but, did you delete successfully those original swapfiles and get them replaced by a new swapfile0 and swapfile1, etc. or what is the explanation of the dates being out of order?



[ Reply to This | # ]
Later swapfiles have earlier dates?
Authored by: johnsawyercjs on Mar 13, '05 03:45:21AM

I'm not sure how you perceive that the swapfiles listed in SOX's post are in reverse chronological order:
10 Dec 18:17 swapfile0
10 Dec 19:43 swapfile1
13 Dec 16:36 swapfile2
14 Dec 14:37 swapfile3

Swapfile0, created first, is shown as being created earlier (10 Dec) than the other swapfiles (with swapfile1 created later the same day), and so on through swapfile3. Last time I looked, Dec 13 and Dec 14 came after Dec 10.



[ Reply to This | # ]
10.3: Use Secure Empty Trash to reclaim hard disk space
Authored by: macmath on Dec 16, '03 03:10:38PM

Panther will give back swapfiles. Particularly if you log out and back in immediately after some heavy usage. Logging out after some heavy usage (and after some swapfiles have recently been created) will quit as many processes as possible. Waiting a few moments and then logging back in will show that some swap has probably been released by the OS. Pather will give back some swap even without logging out, but the maximum swapspace will likely be returned if as much activity is killed as quickly as is reasonably possible after the swapfiles have been created. Try it!



[ Reply to This | # ]
Panther does give back swap without a restart.
Authored by: macmath on Dec 16, '03 03:19:38PM

The above post of mine should read "Pather does give back swap without a restart. I apologize for this extra post, but I wanted to make sure that the point of the post was clear.



[ Reply to This | # ]
Default is for swapfile sizes to double after swapfile1
Authored by: macmath on Dec 16, '03 03:29:49PM

From makern's above post
<i> checked the vm directory & found 6 swap files: 64MB, 64MB, 128MB, 256MB, 512MB & 512MB. </i>

Actually, the 6th swapfile should be 1024 MB, as the size of each new file is the sum of the sizes of all of the earlier swapfiles. Said another way, starting with swapfile2, the size of each swapfile is double the size of the previous swapfile.



[ Reply to This | # ]