A PC has usually two types of memory, storage (HDD or SSD) and RAM (Random Access Memory). If your system runs out of RAM, then a part of storage is used by the system as RAM called the Virtual Memory. Hence virtual memory can be said as the overflow of RAM or a temporary extension of it.
RAM is faster whereas virtual memory is slower. Keeping this in view, the Windows OS loads memory demanding applications/ games on RAM, whereas, less memory demanding processes are paged to the virtual memory, that is why it is called a Page File. For modern Windows apps (downloaded from Microsoft Store), the virtual memory uses a swapfile.sys along with pagefile.sys.
To clear the concept, let us take an example. If you are working on Photoshop and then launch the Word application, then the system may page out the Photoshop to the virtual memory to make the maximum amount of RAM available to the Word processor as it is being actively used. Remember that the system may use virtual memory for some sections of programs even if the free RAM is available, which gives the system ability to save its resources for other heavy tasks that may be launched later.
Additionally, the paging file is also used for the system’s crash dumps (BSODs) and if your system’s virtual memory is not large enough, the system may fail to create a dump of the contents in the RAM. The virtual memory may play part in extending the battery life of laptops or notebooks as it is persistent memory that uses less power (as compared to RAM) to store the data.
- Location of the Page File
- How to Check the Current Size of the Virtual Memory
- Should You Use a Dynamic Page File or Custom Size
- How to Calculate the Best Size of the Virtual Memory on Your System
- How to Increase Virtual Memory in Windows
- Disadvantages of Using Custom Size Page File:
- Impact of Disabling the Page File
Location of the Page File
The virtual memory of a system can be set on a single drive or may be expanded to all the drives of the system. It should be kept in mind that a page file on the SSD may perform faster (not as good as RAM) as compared to the page file on HDD.
It is always best to use the fastest drive for the paging file. The page file of a drive is found in the root directory of the drive but a user must enable viewing of the hidden and protected operating system files to see the pagefile. For example, open This PC > C drive, then you can notice the pagefile.sys there.
How to Check the Current Size of the Virtual Memory
You can find the current virtual memory used by your system by following the undermentioned steps:
- Click Windows, type, and open System Information.
- Now, in the System Information window, scroll down till you find the Total Virtual Memory and that is the amount of the virtual memory used by your system.
Should You Use a Dynamic Page File or Custom Size
Microsoft recommends using the Automatically Manage Paging File Size for All Drives. This has been the default feature originating from Windows 95. If there is no requirement, then you should use the dynamic paging file as it will grow as per the system requirements and will shrink when not in use.
If you do not want to use a dynamic page file, your system shows you a Low on Virtual Memory message, or the system crashes or becomes unstable, then you may set a custom size for the page file.
Keep in mind if you are seeing a low on virtual memory message, then first make sure your system drive has enough free space available to allocate to the page file.
How to Calculate the Best Size of the Virtual Memory on Your System
Technically, you can set the virtual memory to a limit up to the storage capacity of your drive but that would be overkill and extra memory may not be used by the OS.
Once there was a rule of thumb to set the virtual memory of the system to 1.5x or 2x size of the RAM e.g:
If your system has 2GB RAM, then you should set the virtual memory to 3GB
(1.5 * 2GB = 3GB) or 4GB (2 * 2GB = 4GB)
But with the advancement in technology, especially keeping in mind the memory compression mechanism that compresses the contents on the RAM before paging it to the virtual memory, the mentioned formula is no longer viable.
For example, if your system has 16GB RAM, then you may have to set the virtual memory to be 32GB, which is not viable anymore. Also, the virtual memory uses the basic size calculation in MBs. To better understand it, you should keep in mind that:
1024MB = 1GB or 2048MB = 2GB
Moreover, if you are using a 32-bit version of Windows, then the virtual memory size must not exceed 4GB as the 32-bit OS has a 4GB size limit. If you set up a virtual memory of more than 4GB on an X86 machine, then the system will only use 4GB of it.
How to Increase Virtual Memory in Windows
The virtual memory of a system can be increased by either the Advanced System Settings or from the command prompt. Although, there also exists a method to edit Boot.ini to increase the virtual memory size, that will be beyond the scope of this article.
Keep in mind that increasing the virtual memory of the system is usually a safe process but if you start seeing the reliability issues, then decrease the virtual memory to the value where your system stays stable.
For a common user, virtual memory of 4GB (i.e., 4096MB) will be sufficient. For some advanced users, they may have to set virtual memory beyond that.
Through Advanced System Settings:
- Click Windows, type, and open Advanced System Settings. You can also use Settings > System > About > Advanced System Settings.
- Now, in the Advanced System Settings window, click Settings under Performance and head to the Advanced tab.
- Then click on Change in the Virtual Memory section and uncheck the checkbox of Automatically Manage Paging File Size for All Drives.
- Now enable Custom Size and in the Initial Size box, enter the Recommended value.
- Then, in the Maximum Size, enter the Currently Allocated value and click Set. In the case of a 32-bit version of Windows, set the Maximum value to 4096.
- Now apply your changes and restart your system for changes to take effect.
Through the Command Prompt
- Click Windows, search for Command Prompt, right-click on it, and select Run as Administrator.
- Now click Yes if UAC prompt received and then execute the following to know the current size and location of the pagefile:
wmic pagefile list /format:list
- Then disable the auto-management of the pagefile by executing the following command:
wmic computersystem where name="%computername%" set AutomaticManagedPagefile=false
- Now, execute the following but make sure to replace the initial size and maximum size with your required values (e.g., initial 9216 and maximum with 12288):
wmic pagefileset where name="C:\pagefile.sys" set InitialSize=YOUR-INITIAL-SIZE,MaximumSize=YOUR-MAXIMUM-SIZE
- Now execute the following to restart your system and upon restart, the virtual memory size will be set as per your requirements (you can confirm the same by executing the command in step 2 in an elevated Command Prompt):
shutdown -r -t 00
Disadvantages of Using Custom Size Page File:
The main disadvantage of using a custom size page file is the continuous use of the storage device, which may badly impact the life span and performance of the storage device.
Many people think that a bigger virtual memory means good performance and higher speed but actually, a bigger virtual memory decreases the speed of the system (as it is quite slower as compared to the RAM) but may increase the system stability. If you need a bigger memory, then adding a bigger RAM is more viable than increasing the size of the virtual memory.
Impact of Disabling the Page File
After reading the disadvantages of the page file, some of you folks may be thinking to disable it permanently, but don’t do that.
Firstly, the above disadvantages are mainly because of the custom-sized page file.
Secondly, disabling the page file has its repercussions as applications and Windows are not allowed to offload their less-priority processes and thus may badly impact the system’s performance/ stability as the RAM may get choked. Moreover, do note that some applications also need a specified size of virtual memory and you may have to set a custom size of the virtual memory for these applications to work properly.