macOS and swap

Questions and Answers about all things *OS (macOS, iOS, tvOS, watchOS)

macOS and swap

Postby henriok » Tue Jun 20, 2017 8:18 am

We are running several macOS instances in ESXi and use a ZFS based SSD storage system. We are thinking about putting the virtual memory files from the macOS guests on a disk residing on a part of the storage array that doesn't use all the fancy protection technologies that ZFS offers, i.e. dedup, checksumming, snapshotting, etc. I've been tinkering with
Code: Select all
sudo sysctl vm.swapfileprefix=/Volumes/Swap
and it successfully moves the swap to the right place. It doesn't persist between reboots but that can be scripted so I'm not really concerned with that aspect.

I am however interested in a more enlightened take on swap, macOS and if we really are doing something useful with this exercise. What about disabling swap altogether?
henriok
 
Posts: 1
Joined: Tue Jun 20, 2017 6:49 am

Re: macOS and swap

Postby morpheus » Wed Jun 21, 2017 12:59 am

MacOS uses swap, even though doing so on an SSD is far from wise - Flash memory and swap do not go well together (due to P/E cycle limitations). This is why none of the mobile variants of OSes (Android, iOS) use swap. These mostly use Compressed RAM (i.e. swap to RAM, like Linux's zram/zswap). You can see these with process explorer , or with Apple's CLI tool of memory_pressure

Disabling swap altogether is possible, but will inevitably lead to low memory conditions. In MacOS, memory status kicks in and idle exits processes. Whether or not you can disable is a factor of how busy your instances get, and would likely require testing. Just know, that excessive swap can wear out flash - make sure there is a lot of flash space so FTL can kick in and spread out P/E.
morpheus
Site Admin
 
Posts: 532
Joined: Thu Apr 11, 2013 6:24 pm


Return to Questions and Answers

Who is online

Users browsing this forum: No registered users and 4 guests