WhatÂ is the Mac swapfile? Is it important? Can you delete it?Â We’ll walk you through this mysterious Mac file and what you can do about it.
If you’ve even run out of disk space on your Mac, you’ve probably sat and taken some time to look and see what’s eating up all this space (pro tip: it’s easy to forget how many files you move to the Mac Trash folder; the first thing you should do when you run out of space is right-click on the Trash icon on the dock and selectÂ Empty Trash).
You might have run across something called swap, or a swapfile. It can be difficult to understand just what these files are, and whether you can manage to do without them,Â especially since they seem to just sit there and take up space; sometimes they take up quite a lot of space indeed.
What is the Mac swapfile?
Before we delve into what the swapfile is, we have to talk about swapping in the context of how your computer works. When you run a program on your Mac, it gets loaded into your memory (RAM). You haveÂ a much smaller amount of RAM than you do storageÂ on your SSD.
Occasionally, if you’re doing something that requires a lot of memory, you’ll come up againstÂ someÂ of the limits that come with having limited RAM. Enter paging. PagingÂ is what we call using your storage drive as memory. It’s all done automatically by your computer, so you never tend to notice when it happens. While the terms originally meant something different, these days paging and swapping are largely synonymous.
When you write something to your disk, it isn’t always written in contiguous stretches of storage; instead it might be written in a number of places, wherever your Mac (PCs do this, too) finds an open spot.
In order for swapping to work, your Mac usually needs one of those contiguous stretches, which can be difficult to find on a drive as it increasingly fills up with data. To mitigate this, OS X will generate a number of these swapfiles so that it can write (or page, or swap) to them whenever it needs them.
You can find them byÂ navigating to an arcane folder deep within the bowels of your Mac. Just click on an open part of your desktop and mouse up to the bar at the top of your screen. Click onÂ Go, and in the drop-down menu, click onÂ Go to Folder.
A box will appear with an address bar in it; you’ll want to copy and paste the following location into it:Â /private/var/vm/Â and hit enter. Finder will pop up with a new window listing the swapfiles your Mac currently has active.
How many files appear depend on a number of factors: how much and howÂ often the Mac has needed to swap to your storage drive (which itself will depend on how much memory you have and how many programs you use that may have memory leaks). For reference, the above swapfiles were generated on a Macbook Pro with 16GB of RAM; it’s gone around ten days since it was last rebooted.
Can you delete Mac swapfiles?
Yes, youÂ can delete them. You can even tell your Mac to never swap again. But you shouldn’t. Even on systems that have a lot of memory, your Mac might find a need to swap to its storage space instead of use its primary memory, or RAM.
If you delete your swapfiles, you might cause your system to crash, as it’s possible that your Mac is using one of them right as you delete it. The same goes for whether you should disable the ability for your Mac to use swapfiles in the first place – the best result is that you won’t notice a difference, and it’sÂ more likely to make your MacÂ increasingly unstable.
If you really need to free up some space taken up by your Mac’s swapfiles, there’s an easy and simple fix: just reboot your Mac. Shut it down and restart it, and then check your swapfile directory again – they should either be gone or substantially reduced in size.
Chances are good that on a new Mac you’re unlikely to run into issues where your swap is seriously impacting how much free spaceÂ you have. Should you keep running into an issue, however, take a look at the apps you run on a regular basis, and try playing around with them one at a time.Â You might find that one app has a memory leak, and by rebooting after use or finding an alternative app, you can avoid the big swapfile issue altogether!