Upon request, in any search engine “windows paging file” you can get a thousand or other copies copied from each other, or slightly different answers on the choice of optimal sizes for pagefile.sys.
The most common tips look something like this: for machines with small RAM, you need to set the size of the paging file k * RAM, where RAM is the amount of physical memory, k is some ratio, of which there are many different ones. And 1.5, and 2, and even 3 met. If the memory bar is 4GB or more, then “safely turn off the virtual memory in principle.”
An article about whether to believe these tips, and if so, how much.
What is a paging file?
pagefile.sys , also known as the paging file, is a virtual memory file that allows you to simultaneously run a large number of processes that everyone could not immediately fit into physical memory.
By default, after installing Windows, the paging file increases automatically when the current volume is filled.
')
If you disable the swap file
If you try to disable the paging file in windows 7, the system will display a warning window, which will report unpleasant consequences:

It follows that you should not completely abandon the use of virtual memory, otherwise in the event of a crash you will not even be able to analyze the cause of the failure. The minimum size of 1MB specified in the screenshot is taken from the calculation of the configuration of the memory dump in the “boot and restore” settings:

If you select a full dump for recording debug information, the size increases by several orders of magnitude. I got it 400MB.
In addition to the inability to write a dump, after disabling the paging file, an annoying message about a lack of memory may appear. Its appearance will be accompanied by terrible brakes demanding applications.
If you move the page file to another section
A bunch of articles on optimizing your OS recommends transferring the paging file to a separate hard disk partition created and formatted in FAT32. This increases speed and decreases the fragmentation of this file.
With such manipulations, you should not forget that the paging file must be present in the system section in order to correctly record debug information. We have to choose between speed and the ability to collect data on the troubles.
Swap file size
Let's return
to our oranges to the question of the optimal size. Having dug over many articles, informational publications, and even Microsoft recommendations, I never found a clear and unambiguous answer to this question. And I would not have found it, as it became clear to me after reading the translation of the article by Mark Russinovich.
Overcoming the limitations of Windows: virtual memory . In conclusion, I will provide links to the translation and the original, and now I will try to explain how to get the file size.
To start, you will need the Process Explorer utility, it is a free analog of the default Task Manager, but it has many advantages. You can download the
link .
After starting Process Explorer, select the most demanding in terms of memory used by the applications you use in everyday life, and run them all at the same time. In the Process Explorer window, press CTRL + I or select View / System Information from the menu; from the variety of data presented in the window, select the Commit Charge area

The Peak value is the peak value of the allocated memory for all applications, added from physical and virtual memory.
Next, we arm ourselves with a calculator and subtract the size of RAM from this value. If a negative value is obtained, we take the 400MB required by the system (maybe another value) necessary to create a dump. If a positive value is obtained, set the minimum and maximum values for the paging file. It is possible to insure and set a “maximum reserve” higher, but then the file fragmentation will grow in case of increase in its size. Therefore, it is better to fix in one place.
Literature
Article Mark Russinovich
Pushing the Limits of Windows: Virtual Memory ;
Translation into Russian
Overcoming the limitations of Windows: virtual memory ;
Description of
Process Explorer .