pagefile.sys is virtual memory, and shrinking it is usually a mistake
The other large hidden file at the root of C. What it does, why Windows manages it better than you can, and the one case for moving it.
pagefile.sys sits next to the hibernation file at the root of C: and is the other large thing people find when they turn on hidden files. Unlike the hibernation file, this one is usually a bad idea to touch.
What it is
Virtual memory. When physical memory fills, Windows moves less used pages of memory to disk so that something else can have the RAM. It also holds crash dump data, which is why a machine set to write a full memory dump needs a page file at least as large as its RAM.
swapfile.sys beside it is a smaller, related file used specifically for suspending Store apps. It is managed the same way and is usually a few hundred megabytes at most.
Why disabling it goes wrong
- Applications crash rather than slow down. With no page file, a machine that runs out of memory has nowhere to put anything, and programs fail instead of degrading.
- Crash dumps stop working. Diagnosing a blue screen afterwards becomes much harder.
- Some software refuses to run. Several professional applications check for a page file and will not start without one.
- The gain is small. It is typically a few gigabytes on a modern machine, which is rarely the difference on a full drive.
The one change worth making
If you have a second physical drive, the page file can live there instead. That frees the space on C without removing the function, and on a machine with a fast second drive it costs nothing in speed.
- System Properties, Advanced, Performance Settings.
- Advanced tab, Virtual memory, Change.
- Untick Automatically manage.
- Set C to No paging file, and the other drive to System managed size.
- Restart.
Do this only with a second physical drive. Moving it to another partition of the same disk gains nothing and can make things slower.
Checking what yours is doing
Get-CimInstance Win32_PageFileUsage |
Select-Object Name, @{n='AllocatedMB';e={$_.AllocatedBaseSize}}, @{n='PeakMB';e={$_.PeakUsage}}The peak figure is the interesting one. If peak usage is far below the allocated size, the file is larger than this machine has ever needed, and Windows will shrink it on its own when the space is needed elsewhere.
The file that genuinely is worth removing on many machines is the hibernation file, which is a different thing with a different trade.
Common questions
Can I delete pagefile.sys?
Not in Explorer, because it is in use, and you should not want to. It is virtual memory: without it, a machine that runs out of RAM crashes programs instead of slowing down, and crash dumps stop working.
How do I move the page file to another drive?
In System Properties, Advanced, Performance Settings, Advanced, Virtual memory, untick automatic management, set C to no paging file and another physical drive to system managed, then restart. Only worth it with a second physical disk.
What is swapfile.sys?
A smaller companion to the page file used for suspending Store apps. It is managed by Windows in the same way and is usually a few hundred megabytes.
How big should the page file be?
Let Windows manage it. The peak usage figure from Win32_PageFileUsage tells you what the machine has actually needed, and it is usually far below the allocated size.