21.09.2024
Home / Windows overview / Complete configuration of the Windows swap file. A paging file - why is it needed on a computer, why does the system “slow down” without it? How swapfile works

Complete configuration of the Windows swap file. A paging file - why is it needed on a computer, why does the system “slow down” without it? How swapfile works

The article describes the purpose of the paging file, the advantages of placing it on another physical disk, and also provides step by step instructions on moving it to Windows.

A note about links in this article

The first version of the material was written a long time ago, and during this time the pages of Microsoft sites have changed or disappeared completely. You can view their previous contents using the Internet archive, although in the Russian Federation it is Roskomnadzor. Since current pages with this information no, I decided to leave the links “as is”.

Next in the program

What is a paging file and what does moving it do?

According to the Windows Vista Help, where the page file is called the page file, this is hidden file or files on the hard drive used by Windows to store portions of programs and data files that do not fit RAM. Page file and physical memory or random access memory (RAM) constitute virtual memory. Windows moves data from the page file to RAM and from RAM to the page file as needed to make room for new data. Also called page file.

Placing the paging file on a dedicated partition another physical disk Improves Windows performance by speeding up processing of input/output (I/O) requests. In addition, the file placed in this way is not fragmented, which also improves performance.

How many swap files should there be and where should they be placed?

There is an article in the Microsoft knowledge base (KB307886) that talks about how to move the page file in Windows XP (no newer ones have been published). In particular, the article says that you you can increase system performance and also free up space on the boot partition by moving this file to an alternative section. Unfortunately, the article does not cover one important point.

It makes sense to move the paging file only to a partition located on another physical disk, which I have already mentioned twice in this article.

This, however, is discussed in another article (KB314482), which provides the rationale and advantages of this approach, as well as other tips for setting up the paging file. For example, it says that if there is no page file on the system partition, Windows will not be able to create memory dumps (memory.dmp), which can be useful for troubleshooting OS problems. I recommend that you read this article to better understand the benefits of moving the page file.

As for placing the paging file on another partition of the physical disk on which the operating system is installed, this approach, although it avoids fragmentation of the paging file, does not lead to faster processing of I/O requests, which is much more important for improving OS performance. than a defragmented page file. In Windows XP with one physical hard drive, it was enough to organize defragmentation of the page file using the PageDefrag utility, but in newer OSes it does not work.

If you have two or more physical disks, in accordance with Microsoft recommendations, it is optimal to create several paging files - on the system partition (in fact, to preserve the ability to write memory dumps) and on other physical disks (to increase performance by accelerating I/O operations).

Having several swap files at its disposal, the system itself chooses the fastest option. Therefore, in an SSD+HDD combination, two FPs are useful only when the SSD is loaded to capacity with work. But with a pair of SSDs, two FPs may well make sense, and that’s how I did it.

What size should the partition for the swap file be?

Since the gain from defragmenting the FP is insignificant, it can be ignored and not create a separate partition for the FP (this is definitely not required when placing the second FP on an SSD). In any case, there can be no specific recommendations on the maximum size of the paging file, since everything depends on both the amount of installed RAM and how intensively the paging file is used by the system and applications.

Obviously, the more RAM is installed, the less the page file is used. When the page file size is managed by the system, it maximum size does not exceed three volumes of RAM. In most cases, a partition of this size will be sufficient. Increasing the paging file unnecessarily will not lead to an increase in performance - this will not make the system use it more actively.

How to move the swap file

Conclusion

This article provides recommendations for configuring the paging file to increase performance in Windows Vista and later. In particular, it discusses the issue of moving the paging file to a separate partition on another physical disk, and also offers step-by-step instructions explaining how to do this.

You can find answers to other questions about the page file in a thread on the OSZone forum. In particular, it says how big should the page file be?, Is it possible to work without a swap file and is it good? etc.

It tells you how to determine the optimal paging file size, what to do with SSD drives, and how to set the file size on Windows 7, 8 and 10 (as well as XP and Server - the steps are almost identical).

This article covers the following steps with pagefile.sys(and also swapfile.sys in later versions of Windows): defragmentation, migration, complete shutdown and cleanup. Does it make sense to create several paging files on Windows, on which drives is it better to place them, and what can all this lead to in terms of improving system performance.

Location and visibility of swap files

By default, the pagefile.sys and swapfile.sys files are located in the root of the disk where Windows itself is located (all system folders). Since pagefile.sys is a hidden system file, it is invisible by default: you need to enable display hidden files and folders. In Windows 7, the display of hidden files and folders can be configured in the Control Panel.

Including invisible (hidden) files and folders in Windows 7:

  1. Press the button Start.
  2. Go to Control Panel, then to the section Design and personalization.
  3. Select “Folder Options” -> “View” -> “ Additional options».
  4. Select "Show hidden files, folders and drives."
  5. Click OK to save changes and exit the menu.

IN Windows 10 You can enable the display of hidden files and folders in Explorer:

  1. In the top menu of Explorer, go to the tab View.
  2. Select section Options, in the window that opens, open the tab again View.
  3. Open “Advanced options” and uncheck the “Hide protected system files” checkbox.
  4. Check the box next to “Show hidden files”.
  5. Click “Apply”, then “Ok” to save the changes.

The folder settings menu should look something like this:

Completely disabling pagefile.sys and swapfile.sys

The question of the need to completely disable paging files is equally common concern Windows users 7 and 10, when high-speed or sufficient amount of random access memory (RAM) appears. In the article about it, it was already clarified that it makes no sense to completely disable it.

Reasons not to completely disable sfop (paging):

  1. Some programs and games, and Windows itself, are designed to work with the page file; without it, unexpected errors and glitches may appear.
  2. With a sufficient amount of RAM (8-16 GB and higher, depending on the tasks), 300-500 MB of data will be written to pagefile.sys per day. In other words, the user does not sacrifice anything.
  3. If you have enough RAM, you can set the file size limit to 1 GB and not worry about it in the future.

If you still want to turn off the paging file, Windows 10 this is done as follows:

  1. Right click on menu Start, select item System.
  2. In the left menu, click “Advanced system settings” (you must have administrator rights).
  3. Click Options, open tab Additionally.
  4. In the window " Virtual memory» press the button Change…
  5. Select a line below No swap file.
  6. Click Set, then Yes in the warning window that appears.
  7. Click OK in the Virtual Memory settings window to save changes.

All changes will take effect after restarting the computer. Just in case, you can check whether pagefile.sys has really been deleted and is missing from the system root. If in the future any game or program requires this file or starts generating errors about insufficient virtual memory, you can turn pagefile back on in the same menu.

IN Windows 7 And Windows 8/8.1 To change or delete the paging file you need:

  1. Right-click on the My Computer icon on your desktop and select Properties.
  2. In the left menu, select “Advanced system settings”.
  3. Go to the "Advanced" tab at the top of the window.
  4. In the section Performance press the button Options.
  5. Go to the “Advanced” tab again. In the “Virtual Memory” section of the window it will be written what the maximum size the paging file can occupy at the moment.
  6. By default these Windows versions set the pagefile size equal to RAM. Click Change to set other values.
  7. Uncheck the “Automatically select paging file size” checkbox.
  8. Select item No swap file to turn it off completely.
  9. Click OK and restart your computer for the changes to take effect.

As already stated, Windows 7/8 does not work very well without the pagefile.sys file on the system. It is better to leave the swap size at 512-1024 megabytes for system purposes. This rule works regardless of the amount of RAM on the computer.

Transfer and defragmentation (breakdown)

Transferring a paging file from one disk to another is performed on the same page where you select the file size and turn paging on/off. You can select any of the drives connected to the system, including SSD. The changes will take effect after a reboot: Windows will create new file on the specified disk when the system starts.

Interestingly, on the official Microsoft website there is only information about transferring the swap file. The article contains instructions for Windows XP; no new information has been added on this topic.

The instructions below will help you move pagefile.sys to another drive in Windows 7, 8/8.1 and 10:

  1. Right-click on the My Computer icon on your desktop and go to Properties.
  2. Select “Advanced system settings” on the left, then go to the “Advanced” section.
  3. In the section Virtual memory press the button Change(at the same time, you can set the optimal file size, focusing on the suggestions of Windows and ).
  4. Uncheck the box “Automatically select paging file size” if it was checked there.
  5. On the list Disk [volume label] select disk, select below Specify size and set the file size in megabytes.
  6. Click Set And OK to save changes. Click OK in the system message window, if one appears.

You can select several disks at once and set a different swap size in each of them. In this case, there will be multiple pagefile.sys documents that Windiws will use as it sees fit. For the average user there is no point in doing the partitioning. Defragmenting the page file into several separate files will not speed up the system and will not provide any performance benefits.

In some cases, a minimum size file is still needed on the system disk, and not on a high-speed SSD or flash. This allows you to maintain the ability to diagnose the system when critical errors (BSOD) occur, since debugging data can be written there.

The file split over several disks will look like this:

Swap file on a flash drive

Separately, I would like to mention such a practice as transferring the swap file to a flash drive. Firstly, doing this is quite problematic, since Windows will not list removable storage media in the list of drives for the paging file. Secondly, even if you succeed in transferring pagefile.sys to a flash drive, it may not give any significant result.

On the one hand, the speed of USB 3.0 is really high, especially when compared with HDD:

  • USB 2.0 - up to 480 Mbps (60 MB/s)
  • USB 3.0 - up to 5 Gbps (600 MB/s)
  • SATA Revision 2.0 - up to 3 Gbit/s
  • SATA Revision 3.0 - up to 6 Gb/s

In reality, not every flash drive even works at the maximum speeds of USB 2.0, not to mention 3.0. In such a situation, from a regular flash drive you can get a write/read speed of 30-100 MB/sec or even less. Compared to HDDs, not to mention SSDs, such speeds will not provide any performance gain.

Clearing the contents of the swap file

During shutdown Windows computer erases all data that is in random access memory (RAM). Data from the paging file is not erased by default and remains on the hard drive when the system is turned off. Therefore, in some situations, unauthorized persons may gain access to the information in this file.

For security reasons, you can force Windows to delete the entire contents of pagefile.sys by rewriting all memory locations to zeros. In this case, potential attackers will not be able to get to important documents. At the same time, the owner himself will not be able to access information from the swap, including that necessary for debugging.

There are two ways to force Windows to clear the contents of the page file:

  • Using settings Group Policy Editor.
  • By changing the value of entries in Windows Registry Editor.

You shouldn’t go into the Registry Editor unless you really need to, especially if you don’t have experience working with this section of the system. First you should try to enable file cleaning using the instructions for Group Policy Editor.

This method only works for owners of Pro or Enterprise versions of Windows:

  1. Click Start, enter in the search bar gpedit.msc and open the file.
  2. In the Group Policy Editor that opens, go to the section Computer configuration, then in Windows configuration.
  3. Open Security > Local Policies > Settings on the left side of the window.
  4. On the right side of the panel, double-click on the policy Shutdown: Clearing the virtual memory page file.
  5. In the window that opens, select the item Turn on.
  6. Click OK to save changes. The changes will take effect after the system is rebooted.

If something goes wrong, you can use Registry editor:

  1. Click "Start", then "Run". In the window that appears, enter regedit and press the Enter button.
  2. In the registry editor that opens, you need to find the key (on the left side of the window): HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Session Manager\ Memory Management.
  3. Right-click on any free space on the right side of the window and select from the context menu New -> DWORD Value (32 bits).
  4. The new parameter must be named ClearPageFileAtShutdown.
  5. Double-click on the created parameter and enter in the window that opens 1 in the field Value, click OK to save the changes.

The finished work should look like this:

You must restart your computer for the changes to take effect. Windows will then clear the contents of pagefile.sys every time the system is shut down. To disable paging file cleaning, you need to set the created ClearPageFileAtShutdown parameter to 0 , or simply delete it from the registry. After uninstallation (RMB -> Uninstall), Windows will restore the default value (no cleanup on shutdown).

Attentive users operating system We noticed that a previously unknown swapfile process was hanging in the resource monitor. Swapfile.sys is the swap file. It is physically located on the system disk, next to the files pagefile.sys and hiberfil.sys. It first appeared in Windows 8 and was used for metro applications, and then in the new operating system Windows system 10. As a rule, the size of the swapfile does not exceed 256 MB.

Swapfile.sys, Pagefile.sys and Hiberfil.sys

Like pagefile.sys and hiberfil.sys, swapfile.sys is stored by default in the root of the system drive c:\. It's hidden. You can see it by turning on the display of protected system files in the control panel. Hiberfil.sys stores the contents of RAM when the computer is in sleep mode. Hibernation mode (low power consumption mode) also uses hiberfil.sys. When you enter hibernation mode, all open documents and programs are saved to hard drive. Pagefile.sys is used in Windows when RAM space runs out. At this critical moment, so that the computer does not freeze, but at least continues to work slowly, the system turns to this file for support. Windows stores everything that does not fit in the computer's RAM into it.

What is a swap file?

You may ask, “why do we need another virtual page file?” I will answer. With the advent of Metro-enabled applications, there is a need for a new way to manage memory other than traditional virtual memory or page files. This is how the file “%SystemDrive%\swapfile.sys” appeared. To see this file, you must, as we wrote above, enable the display of protected system files. To do this, open the menu “Control Panel” -> “Folder Options”. Next, go to the “View” tab and uncheck the “Hide protected system files” checkbox. Click "OK".

If the system does not have enough RAM while applications are running, it writes some of the information to the swapfile on the hard drive. This process is similar to the hibernation mode we described above. This mode of operation allows you to pause and resume applications, freeing and loading memory. The introduction of a new paging file allows you to achieve a more uniform load on the computer's RAM.

Let's figure out how it works

1. The Process Lifetime Manager (PLM) detects that the system is low on memory and requests the Memory Manager (MM) to free the working set of a particular process that is responsible for processing Metro style applications.

2. The memory manager moves the memory page from the application's working set to the list latest changes operating system pages (the contents of this list are written to disk)


3. The working set of pages are written asynchronously to the modified list page, as prescribed by the memory manager policy (written intelligently in the background, the write is triggered when there is insufficient free memory)

4. Even after the application is stopped, the working set is written to disk. Memory pages removed from the process will remain intact in the operating system's waiting list. Essentially it's a cache useful pages memory, which, if necessary, can be reassigned to other applications. If the original application needs these pages, they will be quickly returned.


If the user switches to an application while the working set of pages is in memory hard drive(on a modified list or waitlist page), the pages will be immediately added to the application process. If pages are no longer available, Windows will load the application's working set from disk in optimized mode.

Can I remove Swapfile.sys?

The size of the swapfile.sys file is actually not large and, as a rule, does not exceed 256 MB. We do not recommend that you delete this file. By deleting swapfile, you will automatically delete pagefile. Remember that disabling the page file can greatly affect the performance of your computer.

You still decide to disable the paging file. Open the "Start" menu, select "View" -> "Customize" appearance and Windows performance."


In the Performance Options menu, go to the Advanced tab and click the Change button in the Virtual Memory section.


Uncheck "Automatically select paging file size on all drives." Select the system disk and click “No paging file” -> “Install”. The pagefile.sys and swapfile.sys files will be deleted from the selected drive after the system is rebooted.


In order to re-create paging files, select the disk on which we will create the files and click “Size by system” or “Specify size”.

Let's figure out what swapfile.sys is| 2015-08-28 12:15:21 | Super User | System software | https://site/media/system/images/new.png | Attentive users of the operating system have noticed that | dr.web journal key, windows settings, write protection

While working in Windows 8-10 (for example, opening a large number of graphic editors or running the game with elevated system requirements) may run out of space in physical RAM. Therefore, in order running games and applications did not crash, in the OS there is a virtual analogue of RAM “Virtual Memory”, which is a file stored on the PC’s hard drive.

In Windows versions starting from 8, there are two files for swapping RAM: swapfile.sys and pagefile.sys. Below we will consider the first of them.

What is the function of the swapfile.sys file in Windows 10?

Microsoft (Windows developer) has created a store of applications that can be integrated (installed) on its OS. In the operating system in question, this file serves as a paging file for such applications when the PC RAM is full. It is internal to the system and therefore is invisible among its files when installing the OS.

How to remove swapfile.sys?

It is advisable not to delete this file from the operating system. However, if such a need arises, its removal will not be a very critical change in the structure of the OS. To delete, you will need to disable the page file. And this, in turn, will also require deleting the pagefile.sys file.

Note! It's best not to delete any of the swap files. They take up little space and are not a problem when working with Windows.

It was said above that this file is a system file and is not visible by default when opened in Explorer. You can enable the display of hidden and system OS files as follows:

1. You need to click on the “Computer” icon on the desktop. Next, in the dialog box that appears (“Explorer”), click on the square on the right side of the window to expand the line (Ctrl+F1):

2. In the panel that opens, click the “View” tab and click on the “Options” item:

3. In the dialog box that appears, find “Hidden files and folders”, select “Show hidden files, folders and drives”, and then click the “Apply” button, “OK”:

After completing these steps, the file you are looking for, swapfile.sys, will be visible. To remove it, you need to follow the following steps sequentially:

1. By clicking on the “Start” menu, in the “Search programs and files” search field, enter the phrase “Performance” and in the list that appears, select and left-click on the line shown in the figure below:

2. In the dialog box that appears, click the “Advanced” tab and find the “Virtual Memory” subsection. Next in this subsection you need to click on the “Change...” button:

3. In the dialog box that appears, uncheck the “Automatically select paging file size” option, click on the “No paging file” option, click the “Set” button, and then the “OK” button:

After rebooting the OS, the file in question will disappear from the file structure. You can restore it by doing the reverse steps.