Users looking to free up space on their Mac might have noticed that the operating system sometimes reserves big chunks of space for files that apparently just sit there, occupying precious disk space. Those gigabytes of storage reserved as ‘swapfile0′, ‘swapfile1′, and so on appear to have no specific function, so you may well be wondering about their purpose and how to remove them, and even if it’s safe to do so.
Sometimes referred to as a page or paging file, a swap file is space reserved on a computer’s hard drive or SSD as a temporary location to store information that is not in use by the built-in physical memory.
Apple calls this space the ‘backing store’ and it contains a copy of the memory pages used by certain processes. Moving data from the RAM to the backing store is called paging out or ‘swapping out’. If data is paged out, it also means it will be moved back to RAM, a process called paging in or swapping in. When the virtual pages are written to disk, the associated physical pages appear as free space. macOS will only do that when the number of pages in the free list dips below a computed threshold. That’s when the kernel reclaims physical space for the free list by swapping inactive pages out of memory.
To check the swap file, launch Finder and press Command + Shift + G to open the Go To field, then copy and paste the following path:
/private/var/vm/
The virtual memory folder you’ll open also contains the sleepimage file, which is essential because it contains the data the Mac has been storing in RAM before going to sleep. Below the sleep image file you’ll find swap files named successively in numerical order, beginning with swapfile0, then swapfile1, swapfile2, and so on.
If you aren’t afraid of controlling the Mac via text commands, then paste the following into Terminal to find only the swap files and their sizes:
ls -lh /private/var/vm/swapfile*
Swap is used by macOS as a space for better memory management, so as long as you don’t disable it, it is normal to see a certain degree of activity there. Getting fresh information on the state of your Mac’s memory is easy:
Launch Activity Monitor.
Click on the Memory pane.
Check the memory pressure graph and the information next to it, where you’ll find the exact amount of swap being used.
The size of the swap file depends on the version of macOS (or OS X) you have installed. What applies to all versions of operating system, though, is that its numbering starts from 0, and the swap files are usually equal in size. But not in all cases, however. Under macOS High Sierra we’ve noticed 1GB swap files, but in earlier versions of OS X their size ranges from 64MB to 512MB.
Yes, it’s possible to disable swap files, but it isn’t recommendeded. Swap files are essential for a stable system, but since they do occupy precious space you may well be looking to these files when trying to free up disk space – it’s a no-brainer to remove such big files, right?
However, the benefits of more disk space cannot compensate for the resulting instability of the overall system, which is maintained by the use of virtual memory. As such the presence of swap files is mandatory.
By eliminating swap files, you’ll limit the system to only using physical memory that the Mac has, which should not be recommended for Macs with 4GB of RAM or lower. It may result in performance improvements in the short-term, but when the system hits this hardware memory ceiling it will become unstable. Also, the wired memory isn’t released when it becomes invalid, because it is only released when a swap out is triggered. That won’t happen with virtual memory disabled.
Once again, we don’t recommend disabling swap files, so you should do so only if you are aware of what you are doing and why. To disable swap files, run the following command in Terminal to unload the dynamic pager from the kernel, followed by a reboot:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
You can activate this function again with the following command:
sudo launchctl load -wF /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist
Swap files should be kept and are especially important for systems with low amounts of RAM – 16GB or above systems with SSD will likely find no issues in disabling swap files.
If you notice increasing amounts of swap pressure, then it is likely caused by a memory leak: the system pages out only when an application requests memory. If an app leaks the memory, then it will fill up pages of memory with inaccessible data and waste time. That will force the system to push out virtual memory pages for the application, which could have been avoided if the app was working properly and the leaked memory had been reclaimed.
Best Reviews may receive compensation for its content through paid collaborations and/or affiliate links. Learn more about how we sustain our work and review products.
©2012-2025 Best Reviews, a clovio brand –
All rights
reserved
Privacy
policy
·
Cookie
policy
·
Terms
of use
·
Partnerships
· Contact
us
User feedback