Page File and Swap File explained. How to delete Pagefile.sys and Swapfile.sys in Windows 8 or 10.
The Windows operating system uses a page file to store critical Windows elements that it needs fast access to. When the hibernation option has been enabled then roughly 25 percent of the RAM memory is stored in the page file and 75 percent is stored in the hibernation file.
When the fast boot option has not been enabled which would turn on the hibernation feature then the page file becomes larger in order to store more data. The size of the pagefile.sys file therefore is partly dependent on whether the fast boot option has been enabled within Windows 8/8.1 or 10.
The page file was not always present in older versions of Windows, but it is back in Windows 8/8.1/10.
What is the Swap File
The Windows swap file which is stored as swapfile.sys usually in the root directory is a type of virtual memory. It is used when the installed RAM memory is deemed by Windows to be insufficient to run its internal operations. In Windows 8/8.1 and 10 it is also used for other purposes as well.
RAM memory is extremely fast for a computer to access but disk access via a solid state drive or a traditional hard drive is considerably slower by comparison. As such, the repeated use of large swap files is an indication that the computer system would benefit greatly from a larger amount of installed RAM because the memory is acting as a bottleneck and slowing down system performance.
The swap file is not used during a fast bootup process with Windows 8/8.1/10. Only the hiberfil.sys hibernation file is activated for alternative boot paths like the hybrid booting process which speeds up the boot time.
Why Is The Swap File Present?
Beyond the need for greater virtual memory to compensate for limited installed RAM, the swap file is also used in Windows 8/8.1/10 to help when suspending and resuming Metro apps. These were first introduced in Windows 8. They would not work well using the page file construct because the page file is designed to speed up other types of paging activities within the Windows operating system.
How The Page File & Swap File Work In Harmony Together
Whereas the page file can hold items that a user or the system has not accessed in some time, the swap file holds items that were accessed very recently and may need to accessed again very soon. Therefore there is some degree of differentiation between the roles of the swap file and the page file along with the data each contains.
The page file becomes more effective with higher specification machines that can really benefit from the way Windows manages the paging process. In the case of the swap file, this benefits lower powered PCs and Windows tablets which need access to more information because usually the installed RAM memory is more limited.
Both the page file and swap file are configured differently when it comes to space allocation, reading and writing policies, and file size growth. Frequent access and updates to the swap file are fine, but would to be extremely inefficient with the page file. Likely it would create much fragmentation of long term dormant data in the page file if it was accessed and updated frequently which would defeat its purpose.
Because of the specific and more limited role, the swapfile.sys is usually only about 256 MB if system sufficient RAM memory is installed already. One of its main roles is to store Metro apps. This is because they need to be accessed in a different way to regular Windows apps and better suit how the swap file is managed.
How to delete Pagefile.sys and Swapfile.sys
Before deciding to delete these files and gain extra space, you should consider moving Pagefile.sys and Swapfile.sys to another drive in Windows 8/8.1/10. If you are set to delete them, here's how:
1. Press Win+R (or Win+S), enter SystemPropertiesPerformance, press Enter.
2. Go to the Advanced tab. You will notice under Virtual memory the paging file size currently allocated.
3. Click on Change.
4. Uncheck Automatically manage paging file size for all drives.
5. Select No paging file, click Set. You'll be prompted to Restart.
(Steps 2 to 5 from above)
That's it. Upon restart you'll notice that both Pagefile.sys and Swapfile.sys are gone.
Clearing the Page File on Restart
There is the option to clean the page file each time Windows shuts down. Windows uses the page file to save on RAM usage at times. This process overwrites the data with zeros in order to make it unreadable. This process is time consuming when needing to shutdown or reboot more quickly.
However, it is useful if working on confidential files which may still be stored in the page file to clear them out when shutting down or restarting Windows.
Here is the way to do this:
1. Open Regedit
2. Navigate to HKEY_LOCAL_MACHINE\ SYSTEM\ CurrentControlSet\ Control\ Session Manager\ Memory Management
3. Create a new entry in the right pane. DWORD 32-bit value ClearPageFileAtShutdown and set a value of 1
This will ensure that Windows 8/8.1/10 will properly wipe the page file at every shutdown or restart procedure.
Windows Drive Encryption
If a full security package is required to protect data in situations where the Windows operating system crashes before data can be safely overwritten then it is worth considering a package like TrueCrypt. This open source encryption software can encrypt the entire Windows drive so that the page file and swap file cannot even be located. This way, a stolen PC cannot be read for private data, passwords, photos, videos, and more.
See our latest article to learn more about hibernation process and the workings of the hiberfil.sys file in Windows 8/8.1/10.
Still, I wasn't able to replicate your second case in which you still had both pagefile.sys and swapfile.sys on C.
For tricking Windows into moving the swapfile.sys file to your S swap partition, you can try this tutorial: http://www.download3k.com/articles/How-to-move-Pagefile.sys-and-Swapfile.sys-to-another-drive-in-Windows-8-8.1-or-10-00430.
The first, showing my virtual memory settings: http://imgur.com/4myyDY2
The second, showing contents of my C: drive after rebooting: http://imgur.com/FG5rMJ3