In Windows, virtual memory is implemented as a paging file. When physical memory is insufficient for current processes, the system moves the least-used data from memory to the paging file on a hard disk. Proper configuration of virtual memory can improve system performance and stability.
Enabling virtual memory may decrease memory I/O performance. If your ECS instance has insufficient memory, we recommend you first change the instance type to add more memory. If you need to enable virtual memory for specific business requirements, follow the instructions in this article.
Use cases
You may need to enable virtual memory in the following scenarios.
-
Insufficient memory or high memory usage
-
If your system has a small amount of memory (for example, 4 GB or less), you may frequently encounter out-of-memory conditions. Enabling virtual memory helps the system handle more concurrent tasks or applications.
-
If your system monitoring tools show that memory usage is consistently near 100%, consider adding more memory or enabling virtual memory to ensure system stability. Otherwise, some applications or the system itself may crash.
-
-
Running large applications or multitasking
When you run memory-intensive applications, such as large graphics and design software (for example, Adobe Photoshop), data analytics software, or games, enabling virtual memory can ensure these applications run smoothly.
Recommendations
Location of the paging file
-
Avoid the C drive: Do not place the paging file on the C drive (the system disk). The system disk stores the operating system and applications and often has limited space, so placing the paging file there can degrade performance and cause availability issues.
-
Use another partition: Place the paging file on a partition other than the C drive to reduce the load on the system disk and improve virtual memory access speed.
Size of the paging file
-
System-managed size: Let Windows automatically manage the paging file size. The system can dynamically adjust the file size based on current usage to optimize performance.
-
Custom size: If you have specific requirements, set the initial and maximum paging file sizes based on the amount of physical memory.
-
Initial size: Set the initial size to 1 to 1.5 times the amount of physical memory. This provides enough space to handle most memory demands without frequent resizing of the paging file.
-
Maximum size: Set the maximum size to 2 to 3 times the amount of physical memory. This ensures the system runs smoothly under heavy load.
-
Other recommendations
-
Monitor performance: Regularly monitor your system's performance, especially when running large applications or games. If the system frequently uses virtual memory, consider adding more physical memory.
-
Prevent fragmentation: Defragment your disks regularly to reduce fragmentation and maintain paging file performance.
-
Check applications using virtual memory to ensure they function correctly.
Configure virtual memory
The steps in this article are based on Windows Server 2016. The procedure may vary for other operating system versions.
-
On the Windows Server desktop, right-click the
icon and click System. -
Click Advanced system settings.
-
On the Advanced tab, in the Performance section, click Settings.
-
On the Advanced tab, in the Virtual memory section, click Change.
-
In the Virtual memory dialog box, choose one of the following methods: Automatically manage virtual memory, Configure a custom size, or Disable virtual memory.
-
Automatically manage virtual memory
-
Select Automatically manage paging file size for all drives.
-
Click OK to save the settings.
-
-
Configure a custom size
-
Clear Automatically manage paging file size for all drives.
-
Select the drive where you want to store the paging file.
-
Select Custom size, enter the Initial size and Maximum size, and then click Set.
-
Click OK to save the settings.
For example, select the D: drive, set Initial size (MB) to 8192, and set Maximum size (MB) to 16384.
-
-
Disable virtual memory
-
Clear Automatically manage paging file size for all drives.
-
Select the drive where the paging file is located.
-
Select No paging file, and then click Set.
-
Click OK to save the settings.
-
-
-
Restart the ECS instance for the changes to take effect.