What is the benefits of using virtual memory? How much virtual memory should i allocate?

Lionsure 2020-10-10 Original by the website

Divide an area on the hard disk to store temporarily unused data in the memory. This area is called virtual memory. Compared with the hard disk space, the memory capacity is often much smaller, especially before 2005(128MB, 256MB). Now the memory capacity has increased a lot, the smallest is 4GB, the largest is 128GB, and the server has 256GB. Personal computers have 4-32GB of memory, which is basically enough and usually does not need virtual memory; while servers are different, the tasks to be processed are much higher than personal computers, and the memory and virtual memory requirements are relatively high. Setting an appropriate value is the guarantee for the stable operation of server. How much virtual memory should i allocate?

In the case of small memory, if you want to process a file and the remaining memory is not enough to load related programs and data, the system can only move the programs and data that are not used temporarily out of memory and cache them in the virtual memory, and the freed memory is used for load the file currently to be processed. In addition, when processing large files(the file exceeds the memory size), the memory cannot load all the data into the memory at the same time, and can only temporarily cache part of data in the virtual memory or temporary files, and then reload the memory when needed.

 

1. What is the benefits of using virtual memory?

Simply put, virtual memory is used to cache temporarily unused programs and data in memory. Due to the limited memory capacity, and in order to speed up the execution of program, the operating system will try to cache the data in the memory to adjust as needed; as the system runs, we open more and more programs and less and less memory. When the memory is not enough, the system will cache temporarily unused programs(such as a certain software) and related data in virtual memory, which is equivalent to an auxiliary warehouse of memory.

The "Pagefile.sys" is the file name of virtual memory saved on the hard disk. You can check it on the disk where the virtual memory is set. If you cannot find it, you can search.

 

2. How much virtual memory should i allocate?(e.g. 16gb ram how much virtual memory)

Generally speaking, the virtual memory is set to 2 times the memory, especially for the case of memory less than 2GB; if the memory is relatively large (such as 16GB or more), it does not need to be set to 2 times. 16GB RAM, which is sufficient for personal computers without virtual RAM in most cases. The memory is sufficient in most cases. If there is a hint that the virtual memory is insufficient, you can set a few GB appropriately(such as 4-16GB).

For the server, the virtual memory needs to be set higher due to the large amount of requests and data to be processed compared to the personal computer. If the hard disk space is large, it can also be set to 2 times or higher than the memory; if the hard disk space is limited, it can be set according to the demand for virtual memory when the service is in a peak state.

If you have never set up virtual memory, please refer to the article "Virtual memory settings(How to change virtual memory) in Windows 7/8/10, Windows Server 2003 - 2019" for the specific setting method.