Is it safe to delete /private/var/vm (swap, sleepimage)?
Do not delete/private/var/vm
No. /private/var/vm holds the sleep image and, on older setups, swap files. Both belong to macOS. How to check them and shrink swap the safe way.
Verdict: Do not delete. /private/var/vm holds files macOS manages for memory: the sleep image, which is a copy of memory saved when a laptop sleeps, and, on older setups, swap files. Both belong to the system, need an administrator password to touch and come straight back, so restart the Mac to clear swap and leave the sleep image alone.
If this folder or swap is growing, the real fix is less memory pressure, not a delete.
What lives in /private/var/vm
Two kinds of file have lived here:
- sleepimage. The
pmsetmanual on macOS explains that laptops default tohibernatemode 3: the Mac stores a copy of memory on the disk and keeps memory powered during sleep, waking from memory unless a power loss forces it to restore from that image. Desktops default tohibernatemode 0and write no image. The location is set byhibernatefile, which defaults to/var/vm/sleepimage. - Swap files. When apps need more memory than the Mac has, macOS moves less-used pages out to disk. Apple's archived guide About the Virtual Memory System explains that macOS uses space on the boot volume for this rather than a fixed swap partition. The
dynamic_pagermanual still names/private/var/vm/swapfileas the default.
On recent macOS, swap has moved. On the macOS 15.5 Mac we checked this on, /private/var/vm held only a 1 GB sleepimage. The swap files, six of 1 GB each, were on a separate volume mounted at /System/Volumes/VM, and every one was dated after the last start-up. /var is a shortcut to /private/var, so both paths point to the same place.
What happens if you delete it
You can't without an administrator password, and Apple lists /var among the places System Integrity Protection protects. If you did force it:
- The sleep image comes back the next time the Mac sleeps, because macOS writes it each time. You gain nothing for long.
- Swap files hold memory from apps running right now. They are in use, so removing them risks losing that data and crashing those apps.
- Changing settings to stop them means turning off safe sleep or swap behaviour, which trades a little disk space for lost work when a battery runs flat or memory runs out.
How to check its size safely
These commands only read and need no password:
ls -lh /private/var/vm
This lists the sleep image and any swap files with their sizes.
ls -lh /System/Volumes/VM
This lists the swap files where recent macOS keeps them.
sysctl vm.swapusage
This prints total, used and free swap. On the Mac we checked, it showed 6144 MB of swap with 5012 MB in use.
pmset -g | grep hibernate
This shows your sleep mode and where the sleep image is kept.
Without Terminal, open Activity Monitor, click Memory, and read Swap Used and the Memory Pressure graph at the bottom of the window.
The safest way to get the space back
- Restart the Mac. macOS creates swap files as it needs them while the Mac runs. On the Mac we checked, every one dated from after the last start-up, which is why a restart is the clean way to clear swap.
- Find what is using memory. In Activity Monitor's Memory tab, sort by Memory and quit apps you don't need, especially browsers with many tabs and virtual machines.
- Watch memory pressure, not free memory. Green pressure with some swap is normal. Persistent yellow or red means the Mac needs fewer apps open at once.
- Keep free space on the disk. macOS needs room for swap and the sleep image. Clearing caches and old files elsewhere is the safe way to give it that room.
- Leave the sleep image alone. macOS writes it again on the next sleep, so removing it gains nothing.
Warning: don't run sudo rm on anything in /private/var/vm or /System/Volumes/VM, and don't change hibernatemode with pmset to save space. The pmset manual itself tells you to use caution with both settings.
What never to touch
sleepimageand the/private/var/vmfolder.- Swap files, wherever they are.
- The VM volume at
/System/Volumes/VM. pmsethibernation settings, unless you know exactly why you need to change them.
Our guide to memory pressure on Mac explains what the colours mean and when swap is a problem. Nearby system folders need the same respect: /private/var/folders for temporary files and /System/Library for macOS itself.
How Headroom helps
Headroom never touches /private/var/vm or swap: it only ever changes files inside your home folder. In the Space map, this space is part of the "macOS and locked folders" block, so you can see how much of your disk is the system's rather than yours. The map is free and read-only. For the cause of heavy swap, the free Speed tab shows live memory pressure, swap and the apps using the most memory, with a Quit button. The $19 one-time licence covers the fixes on other screens, such as cleaning. See the disk map or download Headroom.
Questions
What is the sleepimage file on a Mac?
It is where macOS saves a copy of memory when a laptop goes to sleep, so the Mac can restore your session if the battery runs out. On laptops this is on by default. The file lives at /private/var/vm/sleepimage.
Can I delete swap files on a Mac?
No. They hold memory from apps that are running, and macOS creates and removes them itself. Restart the Mac to clear swap, and reduce memory pressure so it doesn't build up again.
Where are swap files on a modern Mac?
On recent macOS they sit on a separate volume mounted at /System/Volumes/VM rather than in /private/var/vm. Run ls -lh /System/Volumes/VM to see them, or check Swap Used in Activity Monitor's Memory tab.
Should I turn off hibernation to save space?
On a laptop, no. Changing hibernatemode needs an administrator password, Apple's pmset manual tells you to use caution, and without the sleep image a flat battery means losing unsaved work.