All Products
Search
Document Center

:How do I configure the virtual memory of a Windows instance?

Last Updated:Dec 16, 2024

Note

Disclaimer: This document contains information about third-party products for reference purposes. Alibaba Cloud does not guarantee the performance or reliability of third-party products, nor the impact of operations on them.

Background

Virtual memory is a computer operating system mechanism that extends available memory by using a portion of the disk space. It becomes crucial to enable or configure virtual memory when the physical memory (RAM) is insufficient for system and application demands.

The default virtual memory configuration rules for Elastic Compute Service (ECS) instances are as follows:

  • Virtual memory is enabled by default if it is unconfigured in the image and the memory of the virtual machine is 8 GB or less.

  • No changes are made to virtual memory if it is pre-configured in the image or the system memory exceeds 8 GB.

While enabling virtual memory may degrade memory I/O performance, we recommend that you modify the instance type to increase memory when necessary. If you need to enable virtual memory based on your business requirements, follow the guidelines in this topic for configuration.

Note

This procedure is applicable to Windows Server 2012 R2 and later operating systems.

Scenarios

Common scenarios that may require enabling virtual memory include the following:

  • Insufficient physical memory: Systems with limited physical memory, such as 4 GB or less, may trigger frequent out-of-memory incidents. Enabling virtual memory in such scenarios can allow the system to manage a higher number of concurrent tasks and applications.

  • Running large applications:

    • Graphic and design software, including Adobe Photoshop, AutoCAD, and video editing programs, typically require substantial memory. Enabling virtual memory allows for simultaneous operation of multiple large applications without memory overflow.

    • Games: Modern games, especially at high resolutions, can consume significant memory. Virtual memory can provide a smoother gaming experience when physical memory is insufficient.

    • Data analysis software: Applications for data processing, such as Excel and big data analysis tools, also demand considerable memory for handling large datasets. Virtual memory ensures that these tasks run smoothly.

  • Multitasking: Running multiple applications such as office software, browsers, and music players simultaneously can be memory-intensive. Virtual memory allows for smoother multitasking.

  • System stability: Exhausted system memory can lead to application crashes and system freezes. Virtual memory acts as a buffer to prevent such issues.

  • Development and testing environments: Developers and testers often run multiple virtual machines or containers at once, which requires sufficient memory. Proper virtual memory settings ensure smooth operation without overusing physical memory.

  • High physical memory usage: If system monitoring tools indicate that physical memory usage is frequently near 100%, it may be time to consider increasing virtual memory or physical memory, even if virtual memory is not yet enabled.

Configure virtual memory

Note

Before proceeding, consider the following:

  • Prior to performing high-risk operations, such as modifying instance configurations or data, ensure the instance has adequate disaster recovery and fault tolerance measures in place to secure data.

  • Before modifying instance configurations or data, such as those of an ECS or RDS instance, we recommend that you create snapshots or enable backups. For example, you can enable the log backup feature for an RDS instance.

  • If memory usage is already high and I/O performance is poor, configuring virtual memory may decrease performance. The system may experience minimal performance improvement due to high memory usage, but additional I/O operations caused by frequent memory swapping can degrade I/O performance and reduce overall system efficiency.

  1. Connect to the Windows instance. For connection methods, see Use Workbench to connect to a Windows instance over RDP.

  2. Right-click This PC, select Properties from the menu bar, and then choose Advanced system settings.

    image

  3. In the Performance section, click Advanced, then select Settings.

    image

  4. In the Advanced tab, choose Background services, and then click Change.

    image

  5. Uncheck Automatically manage paging file size for all drives in the pop-up window.

    image

  6. Select the drive where the paging file will be stored, choose Custom size, input the Initial size and Maximum size, click Set, and then select OK to complete the configuration.

    image

Virtual memory configuration recommendations

Virtual memory is a key mechanism for extending available memory in operating systems. Proper configuration of virtual memory in Windows instances can enhance system performance and stability. Below are some recommendations:

Location of virtual memory

  • Avoid using the C drive for paging files: It is highly recommended to avoid placing the paging file on the C drive, which is usually the system disk, and has limited space. This can lead to insufficient space, performance bottlenecks, and fragmentation issues.

    • Insufficient space on the C drive can lead to a gradual decrease in available storage over time, which may result in system performance degradation and availability issues.

    • Performance bottleneck: Placing virtual memory on the C drive, which typically experiences high I/O load. Then it affects read and write operations and reduces overall system responsiveness.

    • Disk fragmentation on the C drive can result from frequent write operations, potentially degrading system performance.

  • Use other partitions: It is advisable to configure virtual memory on the D drive or other non-system disk partitions to reduce the load on the C drive and enhance the efficiency of virtual memory access.

Configuration of virtual memory size

  • Automatic management: For most users, we recommend allowing the system to automatically manage virtual memory size. Windows can dynamically adjust the paging file size based on system usage to optimize performance.

  • Manual setting: For specific requirements, set the initial and maximum virtual memory sizes based on the physical memory (RAM) size.

    • Initial size: 1 to 1.5 times the size of physical memory.

    • Maximum size: 2 to 3 times the size of physical memory.

Precautions

  • Monitor performance: Regularly check system performance, especially when running resource-intensive applications or games. If virtual memory is frequently used, consider adding more physical memory.

  • Prevent fragmentation: Periodically defragment the disk to minimize fragmentation and ensure efficient virtual memory operation.

  • Application usage: Verify which applications are using virtual memory to ensure they work as expected.

Common issues and solutions

  • Out of memory alerts: If the system indicates a lack of memory and virtual memory is in use, check the disk space and consider increasing the physical memory capacity.

  • Performance degradation: If there is a notable decline in system performance, check the available space on the C drive and ensure virtual memory is functioning properly.

  • Virtual memory settings not effective: After configuring virtual memory, restart the instance to apply the changes.