Tag Info

Hot answers tagged

34

wonder why one would want to disable the swap file in Mac OS X. Does it increase performance? Stability? Any downsides? I suppose people would do it for an SSD drive because those drives don't have the same lifetime as standard magnetic spinning-disk drives. There are a more limited number of write cycles, so presumably using them with a swap file ...


24

OS X, like most modern operating systems, uses a virtual memory system for managing memory. Among other purposes, this allows the operating system to treat the computer as having an unlimited pool of memory. To achieve this, the OS will page unused parts of RAM out to a disk store known as the swapfile. Of course, RAM is not unlimited, so OS X groups RAM ...


22

The reason they disabled the swap file is likely paranoia about SSDs having a maximum number of writes per block. Swap files can be written to frequently, possibly causing disk fragmentation (as well as file system fragmentation) and, eventually, possibly causing the disk to fail sooner. That said, this is definitely a case of premature optimization. It is ...


15

/var/vm/sleepimage is used to store the contents of the RAM during hibernation, and the hybrid hibernation and sleep mode that Mac laptops use by default. If you have 8 GiB of RAM, /var/vm/sleepimage takes about 8 GiB of disk space. I don't know why it isn't deleted after waking up from sleep though. It might be to ensure that there is enough free disk space ...


15

Apple documents the lowest levels of the Mach Kernel and the virtual memory subsystem fairly well on the web as part of it's developer documentation. Kernel Programming Guide: Memory and Virtual Memory Since that kernel was developed by Carnegie Mellon University, you can find dozens of papers describing it quite easily. If that is too low level for ...


13

note: copied from SuperUser: For older versions of OSX, see this thread on forums.macosxhints.com. Credit goes to dblu for explaining the use of plutil, ZILjr for introducing the wait4path command, and ekl for simplifying the whole thing by eliminating the need for an intermediate shell script. Complete solution: 1. Open Terminal and make a backup copy ...


12

You have two great answers that explain why this is a bad idea in almost all cases where the system can write to a storage device. The reason you can disable swap is so the system can run on read only media such as a CD, DVD, locked network image using NetBoot or a read only USB fob like the new Lion installer or recovery fob that ships with some macs that ...


12

swapfile0, swapfile1 and so on are swap files. You can sort of think of them like "backup" RAM. When your computer doesn't have enough RAM to accomodate the memory requests of all your programs (which is almost always, this is normal), it uses these files to "write out" part of what it had in RAM. The sleepimage has a very similar use, except it's used only ...


10

They are virtual and cost nothing to make. The VM hands out space to each program that asks for any but leaves tons of room to grow between each real allocation. These virtual addresses get mapped into the real RAM space as needed and mapped out when they are freed or otherwise inactive. They can even get paged to your storage if needed. You can reboot to ...


10

I recently answered a question like yours, so thought I'd restate the major points for you, in case this is still a problem. Mac OS X allocates and uses RAM differently than most versions of MS Windows and can be confusing at times. Microsoft originally built Windows to keep as much memory free as possible. Apple's memory model follows a guideline that ...


9

This is most likely not a problem, and in fact is potentially speeding up your computer. All (most?) operating systems utilise a Disk Cache, which stores some recently accessed files in memory so that repeated access of those files can be sped up. The disk cache on OS X is variable in size, and will appear as "Inactive Memory" being used. If any program ...


8

I'll be the naysayer here: I disabled swap on my late 2008 unibody macbook pro and it improved performance noticably: Less waiting, faster switching between applications. Mind you, I keep an eye on my free memory and I have 6GB installed. The few times that I hit the memory limit, the system crashed :-D On my new MacBook Air I wouldn't dream of disabling ...


8

Looking at your memory usage you don't need more RAM. To answer your questions: Apps may open faster if you are running lots of heavy duty apps, like Photoshop, Xcode, etc… I doubt you'd see much of an increase in the FPS in games. That depends on the video card and how well the game is written. Overall performance increase would probably be minimal. The ...


8

You seem to misunderstand virtual memory. Virtual memory is simply a mechanism that the OS uses to make it look like each program has its own, extremely large (4GB on 32-bit, 16 EB on 64-bit) address space. It also provides a way for the OS to use paging, all while making it look like (to applications) only real RAM is being used. In short, it's only an ...


7

I've been researching this very question for some time, and I've come to the conclusion that while there are several so-called "solutions" offered in various places, none of them really fixes the problem or makes the symptoms go away. The best I've found is techniques that change when inactive memory is swapped, such as the use of the purge command you ...


7

So it appears that Flash is still the main culprit - if you enable any flash in ClickToFlash it stays resident in memory. Following Gruber's advice on Daring Fireball, I've disabled Flash entirely on all browsers except Chrome and this seems to have helped immensely


7

Addition: What Dan Barrett said about the sleepimage re-creation is true. However there's a way to get around it and therefore permanently free the disk space occupied by sleepimage. The whole steps: disable hibernation mode: sudo pmset -a hibernatemode 0 delete /private/var/vm/sleepimage: sudo rm /private/var/vm/sleepimage create an empty file and ...


6

I'm not sure that a swap file of 2MB to 25MB is really something to worry about. It might be more useful to look at the values for Page In and Page Out to determine how often data is being written to the swap. The number of page events can be found using the System Memory tab of the Activity Monitor application. There are a couple of other options that you ...


5

I have found, on my machine, that Mac OS X is a little slow to page the right things out. Whenever doing anything particularly memory hungry, I will often quit a few applications to help it out. Safari is a huge memory hog if it has been running for a while and is top of the list of applications to quit. In my case this was when I tried to run VMWare ...


5

Photoshop takes 70% of your RAM by default when it starts. Whether it's a 2G RAM or 64G RAM machine, Photoshop grabs 70% of the RAM. When calculating how much space Photoshop is wanting for files. look at the document sizes in the lower-left. I believe the second number is how large the file is when open. That can be a much different size than the first ...


5

When the wired and active RAM pass 50% - most tasks are measurably slower. You will see increased paging activity (vm_stat 15 in the terminal - watch for page outs - they indicate some memory had to be written to slow hard drive and constant page out and page in above 10-20 per minute indicates you have a RAM starved system.) When starved for RAM, you can ...


4

My experience is similar to w00t's. I have disabled the swap file on SL and Lion because the performance increase works for me. Wired usage does get out of control after a week or so but a simple reboot fixes that. I do not have a SSD but a slow 5400rpm disk. SSD lifespans aren't actually as bad as people try to make them out to be though. If you're ...


4

Yes and no. Without knowing the model of MacBook and level of Mac OS X - you may have safe sleep enabled by default. Safe sleep writes the entire contents of RAM to the hard drive, so anything that is still hitting the hard drive for IO might slow things down until the OS has suspended all the active applications in preparation for this write. It is ...


4

Yes you can configure the dynamic_pager, but for most it is simpler to just disable it and see which program crashes due to the inevitable out of memory errors. Why would I disable swap file in Mac OS X? Pay attention to programs that implement their own virtual memory / cache / paging systems like virtualization and the Adobe Suite in case you have ...


4

How much RAM does your Mac have? Also, browsers (especially Webkit ones) are known to use huge amounts of memory these days. Inactive memory is put to good use opposed to free RAM which just sits there consuming power. In the case of a browser this enables you to undo closing a tab and still have it's history preserved, etc. You can completely disable ...


4

According to Accessing Kernel Memory on the x86 Version of Mac OS X, /dev/mem and /dev/kmem were removed when Apple released OS X for Intel processors. The (excellent) article also explains how to reenable the memory devices, namely using the kmem=1 kernel boot argument. To set it, open Terminal, type: sudo nvram boot-args="kmem=1" and reboot. The ...


3

Mac OS X provides a demand-paged virtual memory system very similar to the one provided by BSD Unix.


3

This inconvenience is caused by a finder prefs entry: "show in new window: all my files" this is consuming too much mem. Select a different folder and all is fine


3

You don't need any special tools like xcode or a debugger to pick apart the virtual memory system in terms of allocation and summary statistics. I would start with sysdiagnose from the command line and perhaps pass in the PID or process name you care about. It samples that app, but you also have the PID and information on that suspect program with all the ...


3

To re-create swap files, you should restart the Mac (a normal shutdown is all that's needed). Swap files get cleaned up each and every reboot whether you attempted to mess with them or not. I used the word attempted since you can't really delete a swap file from under the system due to how unix (the underpinnings of Mac OS X) works. The best you can do is ...



Only top voted, non community-wiki answers of a minimum length are eligible