Apologies if I misunderstand things completely. I am no developer, so memory management is completely foreign to me. OK. So, stepping back for a moment, I think what's helpful to understand is that one of the VM system’s basic primitive operations is designate that a range of address space corresponds to the contents of a file. That process is called mapping a file and is how, for example, executable files are loaded into memory so that they can be executed. That is, what part of what running an executable actually means is map the contents of that file into memory and start executing at a specific point. Similarly, the basics[1] of swap files are simple create a file and designate which parts of it correspond to specific memory ranges. Mapping VM address space to file ranges with what mmap() does. That is, a low-level mach memory function like vm_allocate() (what malloc calls within its implementation): https://web.mit.edu/darwin/src/modules/xnu/osfmk/man/vm_allocate.html ...basica
Topic:
App & System Services
SubTopic:
Core OS