
Your Mac comes with a set amount of physical memory applications can use. Your running programs, open files, and other data your Mac is actively working with are stored in this physical memory. But that’s a simplification—applications can also use “virtual memory”, which your Mac can compress and temporarily store on disk.
There’s no official way to disable virtual memory on a modern Mac, although this was possible in the days before Mac OS X—now named macOS—was released. While it may be possible to hack your system to prevent your Mac from storing virtual memory on disk, you shouldn’t do this.
What Is Virtual Memory?
While your Mac only has a limited amount of physical memory, it exposes a larger area of available virtual memory to running programs. For example, even if you have a Mac with 8 GB of RAM, every 32-bit process on your Mac is given 4 GB of available address space it can use. Every 64-bit process is given about 18 exabytes—that’s 18 billion gigabytes—of space it can work with.
Applications are free to use as much memory as they want within these limitations. When your physical memory fills up, macOS automatically “pages out” data that isn’t actively being used, storing it on your Mac’s internal drive. When the data is needed again, it’s transferred back to RAM. This is slower than simply keeping the data in RAM all the time, but it allows for the system to transparently just “keep working”. If Macs couldn’t store virtual memory data on disk, you’d see messages asking you to close a program to continue.
This is basically the same thing as the page file on Windows, and the swap space on Linux and other UNIX-like operating systems. In fact, macOS is a UNIX-like operating system itself.
Modern versions of macOS actually go through even more trouble to avoid paging out data to the disk, compressing data stored in memory as much as possible before paging it out.
Where Is It Stored?
Virtual memory data is stored in the /private/var/vm
directory on your Mac’s internal storage if it has been paged to disk. The data is stored in one or more files named “swapfile” and ending with a number.
Most UNIX-like operating systems use a separate partition for the swap file, permanently allocating part of your storage to swap space. Apple’s macOS does not do this. Instead, it stores the swapfile files on your system storage drive. If applications don’t need additional virtual memory, these files won’t use much space. If applications need more virtual memory, these files will grow in size…
The post Why You Shouldn’t Turn Off Virtual Memory on Your Mac appeared first on FeedBox.