<<< Back



FAQ on the swap file

Approximately 75% of the article is the material sent by Andrei Ezhgurov . For completeness, I added a couple of words from myself, and also included here a few tips from the "People's wisdom" on this topic.

What is a swap file?
The swap file (swap file, virtual memory) is a file that serves as a "continuation" of RAM. All programs during their work occupy some amount of RAM: one - more, others - less. If you simultaneously run several applications that occupy a large amount of RAM, it can happen that the physical volume of the installed RAM is not enough for the needs of all programs. Then Windows transfers data from inactive programs from RAM to virtual. When you go to the "snapshot" program, the data from the swap file is transferred to the RAM. This is an exaggerated scheme of work, on which, however, it is possible to understand the processes taking place in the computer's memory.
The physical embodiment of the swap file is the win386.swp file in the Windows directory for Win9x / ME and the file pagefile.sys in the root of the disk where the operating system is installed for WinNT / 2000 / XP.

How to determine the required volume of the swap file?
When determining the volume of a swap file, it is necessary to start not from the amount of RAM, but from tasks that are performed on this computer. To do this, run a monitoring program that can register the volume of the swap file (for example, built-in Windows "System Monitor") and do a typical job for this computer. The maximum amount of swap file that is registered during this session will be the required size.
If you actively use DOS programs, then prepare yourself for the fact that the swap file can be of considerable size: you can limit the amount of memory allocated to DOS applications, of course (this is done in the shortcut properties), but usually nobody does it.

Where to place the swap file?
If the system has several hard drives, then the fastest one. If the hard drive is divided into several partitions, then on the partition located at the beginning of the disk (this may not work for laptops whose hard drives can have data not "on the cylinders" but "on the surfaces").

How to fix the size of the paging file?
Windows 9x / Me actively uses the swap file, significantly offloading the computer's RAM. Microsoft made the swap file dynamic, i.e. The file size varies depending on the needs of Windows, although the best performance of the system is achieved with a static file. There are many reasons for this - Windows does not need to change the size of the paging file each time, fragmentation disappears, etc. To change the settings for the paging file, right-click the My Computer icon and select Properties. Click the Performance tab, and click the Virtual Memory button (Properties-> Performance-> Virtual Memory). In the window that appears, select "Virtual memory settings manually" (Let me specify my own virtual memory settings). If you have more than one hard drive installed, we recommend that you move the paging file from the disk where you have Windows installed on a different hard drive, faster. This should significantly increase system performance. Now set the size of the virtual memory file. The recommended size is at least 2.5 times larger than the amount of RAM. Restart the system and run the defragmentation utility to make sure that the paging file is not fragmented. And if you use a third-party defragmenter, in the options, specify that the swap file is located at the beginning of the disk.

Do I need to capture the maximum size of the paging file?
No way. It is necessary to fix only the minimum size (in accordance with the above recommendations). Fixing the maximum size does not lead to increased performance, but it is a potential source of glitches due to lack of memory.
References (found in some FAQs) to the fact that the lack of fixing MAX will lead to fragmentation of the swap file are not consistent. If the MIN 99.9% of the time is correctly selected, swap will not exceed this value and the swap file will be defragmented. In the same rare cases, when you need more virtual memory, the swap file will really become fragmented, but only as long as the application that needs so much memory is running. As soon as this application is removed, the swap file will automatically decrease to the size of MIN, and the fragmented end of the file will be discarded and the swap file will again become defragmented.

How do I defragment a paging file?
Standard Windows Defrag can not move the swap file. Therefore, it is necessary to use utilities of other companies. IMHO, it is most convenient to use Speed ​​Disk from Norton Utilities (of course, as much as possible newer ones).

I have too large a paging file ...
For computers equipped with more than 64 MB of RAM, you can recommend the following "trick": in the system.ini file, which is located in the C: \ Windows directory, in the [386Enh] section, you need to add the line ConservativeSwapfileUsage = 1.
This will allow the system to not create a swap file without the need. For example, with 128 MB of RAM, you can open up to three office applications, such as Word, Excel and Internet Explorer, while the size of the paging file will remain zero. The same will happen when you start Quake 3.

Does it make sense to use the key ConservativeSwapfileUsage = 1?
This key makes sense to use in the ONLY case - if the hard drive is sorely lacking in space. In all other cases, it does not make sense to use it: this key really reduces the size of the swap file, but at the same time reduces the efficiency of the swap partition, which worsens the overall performance of Windows.
The statement that this key reduces the amount of swap and, therefore, the number of disk calls (which increases performance) is not true - the amount of swap proper when using this key does not change, the algorithm of working with the swap file is changing. The difference is explained by the fact that if there is a key (swap in the style of Win-95), the allocation of space in the file is made as necessary, and if there is no key (swapping in the Win-98 style), Windows reserves a place in the swap file (about 4 Mb, if not I am mistaken) for each task. At the same time, there is no real write to the swap file and there are no additional calls to the disk.

So how can you optimally configure the page file?
If you have several hard disks (not partitions, namely hard disks), then installing the paging file on a different screw than the operating system is usually speedily speeds up.
If you have several hard disks, then the swap file is placed on the fastest one.
If you have several partitions on the screw, then the swap file should be placed on the very first one - physically located first, as access to these areas of the screw is the fastest.
It is advisable to limit the minimum volume of the swap file in order to prevent unnecessary fragmentation of it approximately by the volume of 1-1.5 of your RAM volume (however, if you use graphics or strain the computer with database servers, then you can put 2-3 volumes of RAM).
There is almost no reason to limit the maximum volume, as this can lead to program crashes due to a lack of memory, and if not to limit, then no less than 4 volumes of RAM.
After these settings, the computer must restart and run some defragmenter (such as Norton Speed ​​Disk) to completely defragment the swap file and place it at the beginning of the section.
And lastly, remember that after turning off the computer, the swap file can contain your passwords, logins, the remains of your confidential information, etc., so that enough "educated uncles" from among your well-wishers or competent bodies, having loaded into the DOS and rummaged in scraps Your programs in the swap file can find very interesting things ...