78

/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 ...


39

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 would ...


27

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 ...


25

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 ...


24

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


23

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 ...


17

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 your ...


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 ...


11

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 ...


11

Memory Pressure is a better indicator of the health of the virtual memory system than the traditional UNIX measure of free, inactive and active pages. For a brush up on the previous measure, have a read at: Isn't Inactive memory a waste of resources? Now, the caching of files is drawn as a good thing (green memory pressure) and you will only see the ...


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 ...


10

I can't say much about preventing this, but there is no need to reboot. Just kill Finder, using Force Quit from the apple menu or killall Finder in a Terminal window. A new Finder will then be started in the old one's place.


10

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 ...


9

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

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 ...


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 ...


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 ...


7

This wonderful Apple Support article says it all: https://support.apple.com/en-us/HT201464#memory I'll give the short version here: There are three different types of memory, as you have noticed - wired, app, and compressed. Each of these types do something slightly different. Wired memory Wired memory refers to memory that cannot be taken out from RAM. ...


6

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 ...


6

I had the same problem when I installed High Sierra on external SSD. Volume disk3s4 647DA4A9-7E85-4523-A4D2-F0392D3789D4 --------------------------------------------------- APFS Volume Disk (Role): disk3s4 (VM) Name: VM (Case-insensitive) Mount Point: Not Mounted Capacity Consumed: ...


6

This happens because of a change that happened within the High Sierra versions. It is unknown whether this is a bug, or simply a change of hearts at Apple, but with High Sierra the location of the swapfile was changed from /private/var/vm to /vm, and then in a later update to High Sierra moved back to /privat/var/vm. The best way to proceed is to ensure ...


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 ...


5

Just throwing in my 2 cents for those who wish to disable swap BECAUSE of small SSDs: the sleepimage uses far more disk space. And, for those concerned about the limited life of the SSD (particularly those with MBA's and hard-wired SSD chips that CANNOT be replaced), if your computer sleeps many times per day, the rewriting of the sleepimage may be a ...


5

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 ...


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

Here are some ways to check for issues but I fear they may not be a complete or even the correct solution without more peeking or poking: In another shell after you start your python process (or if you screen / tmux it): df / top -l 1 -S | head -12 vm_stat and vm_stat 600 sudo du -sm /var/vm/* Once you have a good baseline, you can watch things over time ...


4

I have been unable to establish a permanent system boot solution, since 10.10 no longer uses /etc/.rc at boot, and the com.apple.dynamic_pager.plist method has failed.... however... sudo mkdir /Volumes/Swap/s sudo chmod 755 /Volumes/Swap/s sudo sysctl vm.swapfileprefix=/Volumes/Swap/s does change the stored prefix as reported by sysctl vm for the ...


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

Don't remove /private/var/vm it is your swap files which the OS constantly uses. When you need less swap or you reboot the OS will reduce the number of files it uses here.


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 ...


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