Why does /var/vm on MacBook Pro tend to show sleepimage and nothing else?

2020 edition, Catalina 10.15.7 on MacBook Pro.

I've looked at /var/vm (not touching anything in there per advice).

It used to fill up with 1GB files and they'd be deleted upon reboot, but now it's just sleepimage as the only file in there; is this usual, even when doing web browsing or using Pages etc.?

Also, why does it have the option to eject it when it never used to?

I'm slightly confused by this, having used Mac desktops since 2011.


Solution 1:

While APFS does store swapfiles on a dedicated volume within a single APFS container (one in which its APFS volume role is set to VM), this volume gets mounted and overlaid onto the very same /private/var/vm mountpoint which has always been used by macOS / Mac OS X for swap storage from way back before 10.0 (when it was still named Rhapsody and dinosaurs roamed). So when you look inside /var/vm on 10.15.7, you will still see any swapfiles that may be getting created during normal use of your machine.

The real reason that you're no longer seeing these files is because of a very good thing: Your system is managing to handle your workload using just physical (and possibly compressed) RAM and does not need to start swapping pages out to disk. This is due to a combination of things:

  1. Over time, xnu's virtual memory subsystem has been substantially improved and was made to be more aggressive both in finding contiguous free pages and in pooling and purging redundant and stale allocations from swap.
  2. Memory compression was added as an intermediate management strategy between physical and swapped memory, so the kernel no longer starts paging out as soon as you hit your physmem reserve.
  3. Both Apple and third-party developers make reducing resource usage a priority in their continual development efforts, so there are constantly updates being made to your OS and applications which are intended to lower their memory footprints.

So rest easy and enjoy knowing that your system is running more efficiently and more quickly due to a great deal of effort by many engineers all across the software stack over the course of many years.

You can confirm that there is no swap being using by using Activity Monitor's Memory tab. Pay attention to the Swap Used and Compressed fields at the bottom of the window.