An essential part of the built-in memory management system is virtual memory, which allows the system to outgrow the limitations of physical RAM. Since physical memory (alongside the CPU) is in high demand and short supply, the applications you install on a Mac will fight for every single bit available.
While it comes at a certain cost, virtual memory helps the system to escape from the limitations imposed at the moment of purchase – specifically how much RAM your budget allows – and plays a key role in providing a good user experience regardless of memory restrictions.
When an application asks for memory space for its processes and data, and there is no free space available, the system checks if there is any occupied but without recent activity. If there is, the system creates a ‘backing store’ on the startup drive, a file that it writes these processes and data to. This process is called page-out or swap-out and the backing store is called the swap file.
Since the swap file (or files, depending on the amount of memory used) is a component of the virtual memory, it contains the virtual address of the processes paged out from the RAM. This file is saved to the startup disk in the dedicated virtual memory directory.
Depending how many apps are running and the pressure they are putting on the memory, you’ll see at least two equally sized chunks of file. In macOS High Sierra, swap files are 1GB in size, but that can vary on older macOS or OS X versions.
Along with the swap files (numbered from 0) in the virtual memory directory, there is also another file called ‘sleepimage’. As the name suggests, this file contains the data located in the Mac’s RAM when it is written to disk just before the computer enters into hibernation mode. Sleepimage relates to memory management since it is preserving existing data in the physical memory, hence its place in the virtual memory directory. When the computer wakes from hibernation mode, the data paged out to the sleepimage file is then paged back into the RAM, so users can continue their work from where they left off.
Virtual memory is useful for the following reasons:
Enabling virtual memory, however, brings disadvantages as well:
Disabling virtual memory is not recommended for systems with low amounts of RAM (4GB and lower), because it will heavily impact overall system stability and the user experience. On Macs with 8GB of RAM or more, virtual memory can be disabled, but we recommend checking its status before doing so. Proceed with disabling virtual memory only if you notice an unusually high amount of swapping.
Fortunately, there is a great command that will show you exactly how the system is handling virtual memory.
To check how macOS uses virtual memory, open Terminal and type in this command, followed by enter:
vm_stat
Terminal then will display the current status of memory usage. If an interval is specified, vm_stat will update the statistics each time this interval is met. As you can see from the example below, vm_stat will display the total number of free, active, inactive, and wired pages, along with the total number of swap-ins and swap-outs.
You can also get some virtual memory usage statistics using the ‘top’ command. To get that data, simply open Terminal and type “top” followed by enter, and you’ll see an updated live list of memory usage alongside other relevant information.
Best Reviews may receive compensation for its content through paid collaborations and/or affiliate links. Learn more about how we sustain our work and review products.
©2012-2024 Best Reviews, a clovio brand –
All rights
reserved
Privacy
policy
·
Cookie
policy
·
Terms
of use
·
Partnerships
· Contact
us