Pagefile.sys is a hidden Windows system file that supports virtual memory. If it is using a lot of disk space, or you want to remove information it may contain, you might wonder how to clear Pagefile.sys. The right method depends on your goal: Windows can clear the file’s contents when you shut down, reduce its size by changing virtual-memory settings, or remove it by disabling the paging file. In most cases, keeping a pagefile enabled is the safest choice.
This guide explains what Pagefile.sys does, how to clear it safely, and what to consider before changing its size or disabling it in Windows 10 or Windows 11.
What Is Pagefile.sys?
Pagefile.sys is a Windows system file used as part of virtual memory. When physical RAM is under pressure, Windows can move some memory data to this file on the storage drive. This helps the system continue running when applications need more memory than the available RAM can comfortably provide. Windows may also use the pagefile to support certain crash-dump settings.
The file is usually stored on the Windows drive, often C:\, and is hidden and protected by default. Its size depends on your Windows settings, available storage, installed RAM, and system workload. With system-managed virtual memory, Windows adjusts the pagefile as needed.
Pagefile.sys is not the same as the hibernation file, which is commonly named hiberfil.sys. Deleting or changing the hibernation file will not clear the pagefile, and clearing the pagefile will not turn off hibernation.
Can You Delete Pagefile.sys Directly?
You generally cannot delete Pagefile.sys while Windows is running. Windows may be actively using the file, so File Explorer will normally prevent you from removing it. Trying to force-delete a protected system file is not a safe way to manage virtual memory and can cause performance problems or application errors.
If your goal is to remove Pagefile.sys entirely, you must first disable the paging file through Windows settings and restart the computer. Windows can then remove the file. However, disabling the pagefile is not recommended for most users. It may lead to low-memory errors, unstable applications, or an inability to create some types of crash dumps.
If you simply want to clear the data stored in the pagefile, use the Windows shutdown-clearing option instead. This clears the file’s contents during shutdown but does not necessarily remove the file or reduce its size.
How to Clear Pagefile.sys Contents at Shutdown
Windows includes a security setting that clears the paging file when the computer shuts down. This is useful if you are concerned that sensitive data could remain in virtual memory after shutdown. It is different from deleting Pagefile.sys: Windows keeps the pagefile available but overwrites its contents during the shutdown process.
Option 1: Use Local Security Policy
- Sign in with an administrator account.
- Press Windows + R, type secpol.msc, and press Enter. If Windows says it cannot find the file, your edition may not include Local Security Policy; use the Registry Editor method below.
- Open Local Policies, then select Security Options.
- Find Shutdown: Clear virtual memory pagefile in the policy list.
- Open the setting, select Enabled, and choose OK.
- Restart or shut down Windows for the setting to take effect.
Clearing the pagefile at shutdown can make shutdown take longer, especially if the pagefile is large. The delay is expected because Windows must clear the file before powering off.
Option 2: Use Registry Editor
Registry changes can affect Windows, so follow the path carefully. Consider creating a restore point or backing up the registry before making changes.
- Press Windows + R, type regedit, and press Enter. Approve the administrator prompt if it appears.
- Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management.
- Find the ClearPageFileAtShutdown value. If it is not present, create a new DWORD (32-bit) Value with that exact name.
- Open the value and set its data to 1 to clear the pagefile at shutdown.
- Close Registry Editor and restart the computer.
To turn this behavior off later, change the value to 0. A setting configured through your workplace’s policies may override a local setting, so check with your IT administrator on a managed computer.
How to Reduce the Size of Pagefile.sys
If the pagefile is taking up too much space, you can adjust its virtual-memory settings. Reducing its size is not the same as clearing its contents, but it may reduce the amount of storage Windows reserves for it. For most computers, leaving Windows to manage the pagefile is preferable unless you have a specific reason to change it.
- Open the Start menu, search for View advanced system settings, and open the result.
- Under the Advanced tab, find the Performance section and select Settings.
- In the Performance Options window, open the Advanced tab.
- Under Virtual memory, select Change.
- To let Windows manage the size, select Automatically manage paging file size for all drives.
- If you need to change it manually, clear that checkbox, select the relevant drive, and choose a paging-file option. Select Set, then confirm the prompts.
- Restart the computer if Windows asks you to do so.
Before choosing a custom size, consider how much RAM your computer has and how you use it. A pagefile that is too small can cause memory-related errors when you run demanding applications or many programs at once. There is no single custom size that is right for every PC, so system-managed sizing is a practical default.
How to Remove Pagefile.sys Completely
If you still want to remove the file, you can disable the paging file from the Virtual Memory window. Do this only after considering the potential downsides, and avoid it on computers that regularly run memory-intensive tasks.
- Open View advanced system settings from the Start menu.
- Under Performance, select Settings, then open the Advanced tab.
- Under Virtual memory, select Change.
- Clear Automatically manage paging file size for all drives.
- Select the drive that contains Pagefile.sys, choose No paging file, and select Set.
- Confirm the warning and restart Windows.
After restarting, Windows should remove the paging file from that drive. Do not try to delete the file manually if it remains visible. Check that the setting was applied, restart again if requested, and make sure you understand the trade-off before using the computer without a pagefile. You can restore virtual memory later by selecting System managed size for the drive and restarting.
Why You Should Usually Keep the Pagefile Enabled
A pagefile is not just spare storage that Windows uses when a computer runs out of RAM. Some applications and system features expect virtual memory to be available, and Windows may rely on the pagefile for crash reporting. Turning it off can cause unexpected problems even if your computer has a large amount of RAM.
For most home and office PCs, the best approach is to keep the pagefile enabled and let Windows manage its size. If you are trying to free disk space, first check the pagefile’s actual size and review other storage categories, such as temporary files, downloads, and unused applications. Those may offer space savings without changing a core system setting.
Common Questions About Clearing Pagefile.sys
Does clearing Pagefile.sys make my computer faster?
Usually, no. Clearing its contents at shutdown is mainly a privacy or security measure, not a performance improvement. Disabling or shrinking the pagefile may make performance worse if Windows or your applications need it.
Will clearing the pagefile free disk space?
Not necessarily. The shutdown-clearing setting wipes the pagefile’s contents but does not promise to shrink or remove the file. To change how much disk space it occupies, adjust virtual-memory settings. Windows may also resize a system-managed pagefile over time.
Can I clear Pagefile.sys without restarting?
Windows manages the pagefile while it is running. The built-in option clears it during shutdown, so you need to shut down or restart for that action to occur. You cannot safely clear an active pagefile by deleting it through File Explorer.
Is it safe to disable the pagefile if I have a lot of RAM?
Having plenty of RAM does not guarantee that disabling the pagefile will be problem-free. Windows features and applications can still depend on virtual memory, and memory use changes as you work. Keeping the pagefile system-managed is generally safer.
Conclusion
To clear Pagefile.sys safely, enable Windows’ Shutdown: Clear virtual memory pagefile setting through Local Security Policy or the Registry Editor, then shut down or restart. This clears the file’s contents but does not remove the file. If your aim is to reclaim disk space, adjust the virtual-memory settings instead, and keep in mind that disabling the pagefile can cause system or application problems. For most users, leaving Windows to manage Pagefile.sys is the most reliable choice.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.