Is there a guide for macOS on the steps you describe at the end, that is on how to allocate a swapfile, Just to be clear, you're not actually creating a swapfile as such. Your mapping a file into memory which means, assuming the mapping MAP_SHARED, the VM system will then use that file as the backing store for that memory range. That gives you basically the same behavior as swap backed system memory, but it isn't ACTUALLY the same as using true swap (for example, you'll be writing the data directly back to file, so there won't be any compression or VM level encryption). mmap that swapfile into memory, mmap is a standard Unix API, which means we don't really provide specific documentation for it, however, there is an old code snippet here showing how it works. One note I will note is that some of the recommendations there aren't really relevant anymore, particularly any recommendation about limiting mapping size. Those concerns where driven by the limited 32-bit address space, but that's not an issue with 64-b
Topic:
App & System Services
SubTopic:
Core OS