The over simplified explanations of virtual memory found all over the place are accurate as far as they go. What the almost invariably leave out is a full explanation of memory usage in a modern operating system such as Unix, Linux, OS X, and even Windows. I spent nearly a semester in graduate school learning the bits parts and pieces of this and at least another semester integrating it into a coherent concept. Later as an adjunct professor I struggled to explain the concepts to undergraduate graduate students. Suffice it to say I am giving you the highly compressed, essential concepts only version.

At the application layer in a computer, ALL MEMORY IS VIRTUAL. When an application is launched it requests a given amount of address space and that address space always begins at address location 0000. So the OS and every running application have the same 0000 starting address. OS X then takes over and maps those virtual address locations to physical locations in the computer. The first addresses are going to be in wired RAM and serve as a communication and control link between OS X and the particular task. Depending on the needs of the individual application additional Virtual addresses will be mapped to:
  • RAM
  • applicaton files on the hard drive
  • data files on the hard drive
  • Application Program Interface APIs either in RAM or on the hard drive
  • common resources such as font files on the hard drive
  • Swapfiles on the hard drive (whether they are actually used or not)

As the program executes, its requirements are continually changing, as are the available resources due to the exception of other tasks in the system. Again it is the OS that takes responsibility for managing where the addresses are mapped and moving data as needed. Theoretically only data and variables should ever be rolled out to the swapfiles because everything else is a constant already on the hard drive and can be read/reloaded from the original location. How much address space is mapped to the swapfile(s) depends on the memory management algorithms in the OS, and the actual requirements of the programs.

Of course this explanation is greatly simplified because I chose to ignore all the remapping that takes place in RAM as well as the additional complexity added by RAM compression in Mavericks.

So hopefully in answer to your question, the OS may elect to map a portion of the virtual address space requested by an application to the swapfile to speed up the initial page out when required. How much of this virtual address space is mapped to the swapfiles is dependent on the memory allocation algorithms in the OS and to how the application code is written. It does appear from practical experience, later versions of OS X are being more frugal with swapfiles and mapping less swapfile space until it is actually required.



"All you've got to do is own up to your ignorance
honestly, and you'll find people who are eager to
fill your head with information"
--Walt Disney