Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > How to delete swap files?

How to delete swap files?
Thread Tools
chris v
Addicted to MacNN
Join Date: Jan 2001
Location: The Sar Chasm
Status: Offline
Reply With Quote
Dec 21, 2001, 10:47 AM
 
I've got 9 swap files in my ~var/vm folder, and I can't throw them out. They're "owned by root." I logged out, and back in, as this worked the last time I had a huge load of swap files, but this time they won't go away.

Is there an easy way to dump these files that doesn't require logging in as root? (I'm not UNIX literate, and am resisting the concept, since I'm a MAC user. Imnot even sure HOW to log in as root, or to "enable the root user" in Netinfo.) I don't want to blow anything up by typing commands in the terminal, when I'm not really sure what I'm doing.

Help a GUI dummy along here.

CV

When a true genius appears in the world you may know him by this sign, that the dunces are all in confederacy against him. -- Jonathan Swift.
     
Jelle Monkmater
Dedicated MacNNer
Join Date: Apr 2001
Location: World capital of drugs and prostitution. Hmmm... SEXTC...
Status: Offline
Reply With Quote
Dec 21, 2001, 11:14 AM
 
Originally posted by chris v:
<STRONG>

Help a GUI dummy along here.

</STRONG>
Sorry, no GUI for you, I only know the UNIX way. There is probably an app which can help you (BatChmod or XRay or whatever's new from versiontracker), but I don't have it. Here's what I do:

1] open Terminal
2] type:
&lt;font face = "courier"&gt;sudo rm /var/vm/*&lt;/font&gt;
3] Enter your own user password when prompted for one.
4] That's it. Painless, yes?

If you want to delete individual files, fill the name of that file in place of the asterisk. The above command simply deletes all swapfiles.

Two questions you need to ask yourself though:
1] Can I remain UNIX illiterate yet still execute UNIX commands?
2] How hard do I need the HD space?

And, as a general warning:
The 'sudo' commands lets you do stuff as root. The 'rm' command deletes stuff. MAKE NO TYPOS! I'm serious. UNIX isn't deadly, but carelessness isn't advisable when doing stuff like allowing root to delete anything because you will get no warning of things going wrong, they simply will go wrong.

[ 12-21-2001: Message edited by: Jelle Monkmater ]
The one you love and the one who loves you are never the same person.
     
benh57
Senior User
Join Date: Aug 2001
Location: CA
Status: Offline
Reply With Quote
Dec 21, 2001, 11:25 AM
 
Originally posted by chris v:
<STRONG>I've got 9 swap files in my ~var/vm folder, and I can't throw them out. They're "owned by root." I logged out, and back in, as this worked the last time I had a huge load of swap files, but this time they won't go away.
CV</STRONG>

They should be automatically deleted on reboot.

And btw - GET MORE RAM.

-B (pageout? whats that?)
Dual 800 - GF3 - 1.5GB
     
chris v  (op)
Addicted to MacNN
Join Date: Jan 2001
Location: The Sar Chasm
Status: Offline
Reply With Quote
Dec 21, 2001, 11:56 AM
 
Originally posted by benh57:
<STRONG>


They should be automatically deleted on reboot.

And btw - GET MORE RAM.

-B (pageout? whats that?)</STRONG>
Yes, they're automatically deleted on reboot. OS X is supposed to be able to run for long stretches of time without rebooting-- part of it being sold as an advanced OS, with advanced memory management features. Quitting apps should cause the Swap files to go away, but it doesn't neccessarily always work.

I've got 1.2 GIGS of RAM, thankyouvermuch, and had 14 (!) swap files this morning. After 3.5 days uptime. Quitting all apps, logging out, and logging back in only made 5 of the 14 go away. A gig of VM seems excessive to me.

Will try the -rm command. Gotta learn UNIX, I guess. (I'm a simple country Graphic Designer, Jim! Not a Blasted Network Admin!)

OS X easier to use than 9? I think not.

CV

When a true genius appears in the world you may know him by this sign, that the dunces are all in confederacy against him. -- Jonathan Swift.
     
brachiator
Mac Elite
Join Date: Sep 2001
Location: Santa Monica, CA
Status: Offline
Reply With Quote
Dec 21, 2001, 06:17 PM
 
Chris,

There may be a bigger -- well, different -- problem than just how to delete the swaps. I'd be leery of deleting them anyway since they are pretty critical system files, blah, blah, blah.

But the deeper questions are: why are you generating so many swap files -- how many apps are you running, what are they, are they memory-leaky (like the early sp versions of OmniWeb 4.1)?

and also there would seem to be a problem with your OSX vm system that might require more troubleshooting, maybe over in the UNIX forum -- why is it not deleting more swaps when there are no apps to run them -- and on reboot.

I do know that the system won't delete as many swaps as you might think after you quit apps, but it sounds a little much on your system. Also, the swaps are not necessarily deleted immediately on quit -- might take a little while afterwards, or a longer while.

They *are* supposed to be deleted on quitting the system, though...

good luck
"Labor is prior to, and independent of, capital. Capital is only the fruit of labor, and could never have existed if labor had not first existed. Labor is the superior of capital, and deserves much the higher consideration." -- Abraham Lincoln, 1861
     
eno
Banned
Join Date: Sep 2000
Location: Fightclub
Status: Offline
Reply With Quote
Dec 21, 2001, 06:28 PM
 
Am I the only person here who thinks that deleting one's swap files sounds like A DUMB FCUKING IDEA????????!!!!!!

"Oh my god! There are some files in the root directory called 'mach something or other'. They're taking up a few megs so I am going to delete them!"

You've already been told to buy more RAM. I'll add something to that: if you can't fit more RAM in your machine, BUY MORE DISK....

For god's sake...
     
ndptal85
Dedicated MacNNer
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
Dec 21, 2001, 07:56 PM
 
He who deletes his swap files will soon find it self evident why its not a good idea.
Main Computer and EyeTV 200 DVR: Mac Mini Core Duo 1.66Ghz 2GB Ram 160GB HD.
Road Warrior: MacBook White 2.0Ghz Core 2 Duo 2GB Ram 80GB HD.
Kubuntu Book: Dell Lattitude C400 running Kubuntu Linux 6.06 1.33 Pentium 3 CPU 1GB RAM 40GB HD with Creative laptop speakers (it only has one speaker).
     
chris v  (op)
Addicted to MacNN
Join Date: Jan 2001
Location: The Sar Chasm
Status: Offline
Reply With Quote
Dec 21, 2001, 08:37 PM
 
Originally posted by eno:
<STRONG>Am I the only person here who thinks that deleting one's swap files sounds like A DUMB FCUKING IDEA????????!!!!!!

"Oh my god! There are some files in the root directory called 'mach something or other'. They're taking up a few megs so I am going to delete them!"

You've already been told to buy more RAM. I'll add something to that: if you can't fit more RAM in your machine, BUY MORE DISK....

For god's sake...</STRONG>
Look, you arrogant @sshole, I started this out by saying I didn't know much about UNIX, and that I didn't want to root around and trash things without knowing what I'm doing. Can you Ficking read???

I've got a more than a GIG of Fooking RAM-- why after three days of running Illustrator, should I need a GIG and a HALF of hard drive space taken up by Swap Files, after I've Facking quit all my apps, and logged out and back in?

TW@T.

Why doesn't someone whe has a clue about how to speak to other human beings (I'm SORRY SORRY SORRY--I'm just a stinking lowly designer who didn't take 12 stupid years of UNIX classes in College--forgive me in my infinite stupidity) explain to the rest of us bottom feeding users WHY it's not a good idea to delete swap files?

Oh, by the way, they do go away when I restart, but i was getting much better uptime out of OS 8.1 than this.

CV

When a true genius appears in the world you may know him by this sign, that the dunces are all in confederacy against him. -- Jonathan Swift.
     
benh57
Senior User
Join Date: Aug 2001
Location: CA
Status: Offline
Reply With Quote
Dec 21, 2001, 11:20 PM
 
Originally posted by chris v:
<STRONG>

I've got a more than a GIG of Fooking RAM-- why after three days of running Illustrator, should I need a GIG and a HALF of hard drive space taken up by Swap Files, after I've Facking quit all my apps, and logged out and back in?</STRONG>
You have some severe memory leaks, then. My system never pages out. I've never had more than one swap file. Perhaps it is illustrator. Talk to illustrator support.

Anyway, yes, i'd agree deleting swapfiles yourself is a pretty bad idea.

-B
Dual 800 - GF3 - 1.5GB
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Dec 21, 2001, 11:33 PM
 
Will try the -rm command. Gotta learn UNIX, I guess. (I'm a simple country Graphic Designer, Jim! Not a Blasted Network Admin!)

OS X easier to use than 9? I think not.
It's a bug, this does not make it easier or harder to use than OS 9.
     
chris v  (op)
Addicted to MacNN
Join Date: Jan 2001
Location: The Sar Chasm
Status: Offline
Reply With Quote
Dec 21, 2001, 11:45 PM
 
Originally posted by besson3c:
<STRONG>

It's a bug, this does not make it easier or harder to use than OS 9.</STRONG>
I think the point on my part is that I didn't have to know UNIX to turn virtual memory off in OS9.

I do think there's a memory leak on that machine, though. I had Eudora open, and it had been bouncing the "new mail" message since some time in the middle of the night. iCab was open, too, although I don't think I had a window open.

It just seems that quitting all the apps should have worked. I did walk away for about 15 minutes, and they (the swap files) were still there when I came back.

Is there some way to pin down which swap files belong to which app? or was that another UNIX-illiterate boner of a question?

So what DOES happen if I remove the swap files from the terminal?

CV

When a true genius appears in the world you may know him by this sign, that the dunces are all in confederacy against him. -- Jonathan Swift.
     
brachiator
Mac Elite
Join Date: Sep 2001
Location: Santa Monica, CA
Status: Offline
Reply With Quote
Dec 22, 2001, 12:31 AM
 
eno -- see my earlier post, you were not alone in your concerns, although perhaps so in the, uh, color and vehemence of their expression...

chrisv --

**Don't delete the swap files. **

At least not now. There may be some situations in which deleting swaps is fine and necessary, but this is not one of them, at least not yet.

Under UNIX, and thus Mac OSX, there is no (easy or known to me way to "turn off" virtual memory. It is a core system function, as well, and so messing with it is not good.

Besides, your problem is not really the extra swapfiles, but the reason that they are there. If you delete them, they will come back! (Most likely )

There does seem to be some kind of memory leak. Neither iCab nor Eudora should be it, and the "new mail" message should not have been the cause -- I used to run Eudora (beta X) without leak problems.

Why don't you post a list of all the apps you have been running? Thats a place to start. In particular, please post how *many* apps you are running -- 1.5 gigs might be abnormal, or it might be no big deal if you are running 30 apps or 15 memory hogs... YMMV depending on wha you use.

Illustrator was also mentioned. Likely the problem is a leak in one of these -- and it is not always the case that the swaps will disappear when the apps are quit. I think I recalll this discussion in another thread, with the idea that the system will hold onto swapfiles because it is designed to expect to be used again, not with the expectation of not being used, unless shut off.

Anyway, here is a way you can check on the memory usage of your running processes (apps, more UNIX-y term for ya! ) It requires only one UNIX command in the Terminal (or the CLI - Command Line Interface).

Open the Terminal and at the prompt type "top" (without the quotation marks, of course). This will bring up a list of running processes, dynamically updated to show uptime, processor usage, memory usage, etc. I'd recommend making the Terminal window as tall as possible so as to see more apps. To QUIT top, you enter control-c with that top terminal window frontmost. (The control-c is standardly the UNIX "quit" command. Sorry that you have to even be using the CLI, you shouldn't need to, but something is rotten in the state of Denmark).

Ok, so in top you'll see (only going to discuss the relevant parts, since I have no clue what the other parts do!):

the "PID" -- the process ID, the number the system identifies that process by. You can quit an app in the terminal by typing "kill [PID]" if you need to (and sometimes I do when the GUI freezes and all that works is command-tab to the Terminal and running top and kill.

the "COMMAND" is obviously the process name

"%CPU" tells you how much of the CPU time the process is using

"TIME" is uptime for that process

"VSIZE" (all the way to the right) shows you how much virtual memory is being used by this process.

To monitor virtual memory usage, keep top running and keep an eye on the VSIZE of the processes. Of course it will be easier if you are running only one or a handful of your usual apps, but either way it is workable. A pain in the ass, but it pretty much gives you the info you need.

Right after you launch an app, check top for its VSIZE and make a note of it. Some growth is normal, and of course there will be more "normal" growth in VM use depending on how many windows you have in the app, blah, blah, blah.

Hopefully, you'll see something as dramatic as OmniWeb's sneakypeek early builds were, were it was opening up with a VMSIZE of maybe 80megs, and growing over a few hours to over 600megs. That's an easy one to spot, but then those weren't even alphas, but nightly builds that Omni was cool enough to release to the community of geeks here. No retail app should have a memory leak!

Unfortunately, this requires you to baby sit your VM for a while to find the offender. It is not likely to be a "system process" i.e., come unixy sounding thing like nfsiod, or such. So look first to monitor usage for your own 3-d party apps, then the Apple apps, last the unix processes, I'd suggest. Sorry for the long post, but hopefully this will at least get you started. (and I am sure that any mistakes above will be corrected by the UNIX crowd... nothing in top can hurt you, though.. )
"Labor is prior to, and independent of, capital. Capital is only the fruit of labor, and could never have existed if labor had not first existed. Labor is the superior of capital, and deserves much the higher consideration." -- Abraham Lincoln, 1861
     
chris v  (op)
Addicted to MacNN
Join Date: Jan 2001
Location: The Sar Chasm
Status: Offline
Reply With Quote
Dec 22, 2001, 12:55 AM
 
brachiator!

Thank you. That made sense.

I knew about Top, and I'm trying to understand pagein, and pageouts, but didn't what the VSIZE column represented. this gives me someplace to start-- next week when I go back to work. I'm at home on my Cube (896 mb ram) now, and It's never had more than two Swap files, although I use the same installations of the same aps on it... (although not as heavily) Something is up with the tower at work.

Thanks again, that's why I come here-- lots of knowledge, and the occasional nice person.

CV

P.S. I'm cracking the two UNIX books I picked up. you can't ever know too much, I guess.....

When a true genius appears in the world you may know him by this sign, that the dunces are all in confederacy against him. -- Jonathan Swift.
     
brachiator
Mac Elite
Join Date: Sep 2001
Location: Santa Monica, CA
Status: Offline
Reply With Quote
Dec 22, 2001, 01:07 AM
 
Yeah, that's a good idea. I have these 2 unix books I left over at my parents house in, like 1994 or so. Picked them up because I was going to start to use the internet, and it was pretty much all unix. Then that whole "Web" thing exploded like an overripe pustule, and the books began to gather dust. Who'd a thunk that the investment would come in handy 7 years later?
"Labor is prior to, and independent of, capital. Capital is only the fruit of labor, and could never have existed if labor had not first existed. Labor is the superior of capital, and deserves much the higher consideration." -- Abraham Lincoln, 1861
     
Oink
Dedicated MacNNer
Join Date: Jan 2001
Location: the state of the arts?
Status: Offline
Reply With Quote
Dec 22, 2001, 01:13 AM
 
Heh idiot up there who doesn't know anything else but staring at the screen all day looking to submit a bitchy comment,

I can give you (at least) one legitimate reason to delete vm files:
To not backup gigabytes worth of junk when making backup to disk images. I have compressed images (400mb) that I can recreate my OSX environment in 10 minutes on any qualified workstation. Beat that! I suppose back up is also a stupid idea in your mind
     
Drizzt
Mac Elite
Join Date: Jan 2001
Location: Saint-Jean-sur-Richelieu, Québec, Canada
Status: Offline
Reply With Quote
Dec 22, 2001, 01:25 AM
 
I'll try to explain the basics of virtual memory than..

When you start a program, OS X get's the code in RAM and than execute it..

If you go and put too much stuff in RAM (let's say you got 128MB of RAM, OS X takes 60MB, and Illustrator 70MB). So with this case, we are 2 MB short of RAM. With OS 9, Illustrator would not start at all. OS X take out of memory the code that isn't necessary (startup code, rare code, usually it's about 90% of the program itselft!). This explains the difference between resident size (the actual size in RAM) and the Virtual Size (the actual size of everything..).

Let's say mister user is not happy with illustrator, and choose to start Photoshop 7 over it! And, let's say photoshop want 100MB of RAM. now we are 102MB short! OS X will do what I described before, and see that it needs more memory. So it will start to write chunks of memory on the file system in 80MB parts. Let's say he now needs 100MB of RAM.. OS X will write 2 * 80MB swap files, and let 60MB of the last one actually "empty".

In short.. you have much of OS X and Illustrator written on the disk..

Now let's say you delete those 2 swap files.. guess what happens..

Mac OS X : "Hum.. let's go in swapfile0 see if I can my services up again.. Hu? where is it? D'OH!"

And now mister OS X is on crack.. odd behaviors happen..

Hope that helps!
     
T u r b o
Junior Member
Join Date: Nov 2001
Status: Offline
Reply With Quote
Dec 22, 2001, 03:31 AM
 
I disabled swapping quite simply on OSX. Just comment out the line that starts with "dynamic_pager" in /etc/rc.

This disables the use of the swapfile, but not VM entirely (at least, I think. Not sure what the PPC term would be, but in the x86 world it would be comparing memory pages marked 'SWAPPABLE' with memory pages marked 'DISCARDABLE'. Pages marked discardable can be discared, and reloaded from the original binary, which is why you can occasionally see some 'Page Ins' count up in top, even with dynamic_pager disabled). When memory becomes full, the discardable pages are discarded, and then reloaded only on demand, from the original binary.

I find that my G4 w/ 768MB of RAM runs just perfectly with dynamic_pager disabled (though I haven't run any serious benchmarks to compare it on/off). YMMV.

- Mike
     
Jelle Monkmater
Dedicated MacNNer
Join Date: Apr 2001
Location: World capital of drugs and prostitution. Hmmm... SEXTC...
Status: Offline
Reply With Quote
Dec 22, 2001, 04:16 PM
 
There's been another thread on here in which quite the opposite conclusion was reached: it's safe to delete the swap files. It might not be necessary, and it might be fighting symptoms rather than causes, but there is no averse effect on your system.

I should know, as I deleted my swapfiles just to find out and now I only have to restart every hour.. Erm, I mean -haha- my machine never crashes why do you ask?


Seriously, it might be that apps will take a little longer to load the first time after you delete your swap files, as if you just rebooted, but that's the extent of 'weird behaviour' that I've noticed.

But, yeah, listen to brachiator. He's the Mac GUI to my UNIX layer (ie. I simply comply without asking questions - like UNIX - brachiator guides you along like a Mac should).
The one you love and the one who loves you are never the same person.
     
brachiator
Mac Elite
Join Date: Sep 2001
Location: Santa Monica, CA
Status: Offline
Reply With Quote
Dec 22, 2001, 04:24 PM
 
Originally posted by Jelle Monkmater:
<STRONG>But, yeah, listen to brachiator. He's the Mac GUI to my UNIX layer (ie. I simply comply without asking questions - like UNIX - brachiator guides you along like a Mac should).</STRONG>
Why, Jelle, that's the nicest thing anyone's ever said to me on these boards (I think... ) !!

Actually, you just solved a problem I had from another thread -- what to call each new incremental OS update (even if all it affects is FW connections)... I mean "snappier" is played out, even as a joke. It's beyond a meta-joke now, even.

So my new term will be: GUI-er! I'm anticipating the 10.1.3.6.2.3.4.6.7 update to be just ever so slightly -- but noticeably! -- guier.
"Labor is prior to, and independent of, capital. Capital is only the fruit of labor, and could never have existed if labor had not first existed. Labor is the superior of capital, and deserves much the higher consideration." -- Abraham Lincoln, 1861
     
Jelle Monkmater
Dedicated MacNNer
Join Date: Apr 2001
Location: World capital of drugs and prostitution. Hmmm... SEXTC...
Status: Offline
Reply With Quote
Dec 22, 2001, 04:35 PM
 
Originally posted by brachiator:
<STRONG>

Why, Jelle, that's the nicest thing anyone's ever said to me on these boards (I think... ) !!
</STRONG>
Well, you know, credit where credit's due. Besides, I've learned in my time as teacher that positive reinforcement works so much better: don't bring 'em down when they do something stupid, but praise them when they do something good.

Ugh I sound old... I'm only 27. Oh, wait, that probably is old...


But guier it is.
The one you love and the one who loves you are never the same person.
     
   
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 07:27 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,