How to Modify Pagefile.sys in Windows to Your Advantage

What Is Pagefile Sys

If you have stumbled upon the “pagefile.sys” file in Windows File Explorer, you might wonder why a single file is consuming so many gigabytes of space. This file is your PC’s secret safety net and shouldn’t be messed with without knowing what it does. Let’s learn what this mystery file does and how to modify it for your specific needs.

What is Pagefile.sys

Pagefile.sys is a hidden system file that Windows uses as virtual memory. It converts a portion of your HDD or SSD into virtual memory to use it along with your system RAM to manage system processes.

When running processes, Windows will move passive processes from RAM – like minimized apps processes – to the pagefile, which is slow but vast memory. When the system needs those processes, it will quickly move them to the RAM, which is fast but limited memory. This continuous exchange of data prevents RAM from getting full, which can otherwise lead to system crashes.

Pagefile Working Representation

To give you an example, when you move from one program to another that isn’t being used frequently, you will see a tiny delay before the program maximizes to its interface. During that delay, Windows is actually moving the processes of that program from the pagefile to RAM so you can interact with it again.

By default, Windows will dynamically adjust the pagefile size to match your RAM usage needs. For most PCs, it’s starts low, only consuming 1-2GB of space. If your activities consistently consume 90% of RAM+pagefile memory, it will increase the pagefile size automatically. Theoretically, it can go as high as 3x the size of your physical RAM, but for most people, it goes as big as the size of their physical RAM.

In short, the pagefile is an essential safety net. It balances the workload of your hardware, ensuring that your RAM stays focused on your immediate tasks while the hard drive handles the “cold” data in the background.

Should You Disable the Pagefile?

If your PC has lots of RAM, you might be enticed to disable the pagefile to free up space. While technically, you can disable the pagefile, there is a big downside to it. If there is no page file, your RAM will keep filling as you open up more programs and data until it’s full, and the system crashes with a BSOD.

Even if your system has lots of RAM, which your workload can never completely fill, it’s still not recommended to disable the pagefile. Many Windows apps expect the pagefile to be always available. So you will often deal with crashes and errors when you use functions that expect a pagefile, even if your workload technically doesn’t need it.

The only time it’s fine to disable the pagefile is when you need to temporarily free up space in emergencies. Pagefile should never be disabled permanently, as it’s bad for system stability.

That said, if you are still interested in disabling the pagefile, here’s how to do it:

Search “adjust appearance” in Windows Search and open Adjust the appearance and performance of Windows.

Here, move to the Advanced tab and click on Change under Virtual Memory.

Now, uncheck the Automatically manage paging file size for all drives to make all options configurable. Afterward, select No paging file and click the Set button to disable it. You’ll have to restart Windows for changes to take effect.

Disabling Pagefile in Windows

Move or Resize Pagefile Instead of Disabling

A better alternative to disabling the pagefile is to simply move it to another drive that has more free space or manually resize it as per your needs. This way, you’ll still keep the pagefile so the apps and system functions don’t break, and you’ll still free up space in the drive. Here’s a complete step-by-step guide to changing pagefile size and location.

Automatically Clear Pagefile.sys on Shutdown

Another way to modify pagefile.sys to your advantage is to clear it automatically on shutdown. The pagefile is technically capable of storing passwords or encryption keys in plain text, as it works just like RAM, where such information is decrypted. If someone gains access to your storage drive, they can potentially steal the sensitive information. This is why it’s a common practice (often mandatory) in enterprise environments to clear the pagefile on shutdown.

If you don’t want to take chances, you can use a Registry hack to automatically replace the pagefile data with zeros upon shutdown, effectively clearing it. Just keep in mind that this will increase shutdown time significantly as Windows clears it every time.

Warning: make sure you back up the Registry before editing. Incorrect changes in it can lead to system corruption and data loss.

Open the Windows Registry and move to the following location:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management

Here, open the ClearPageFileAtShutdown value and set it to 1.

Editing the Registry to clear pagefile

You can also apply the same edits using a PowerShell command. Open PowerShell as administrator and run the following command:

Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "ClearPageFileAtShutdown" -Value 1

For most users, there is no need to manually manage pagefile.sys, as Windows does a great job of automatically adjusting it. In fact, disabling it will do more harm than good. Either ignore the pagefile.sys file or stick to moving/resizing it if you want to get more storage.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Karrar Haider Avatar