Skip to main content
FixMyTech

Is hiberfil.sys or pagefile.sys Safe to Delete?

By

Published

7 min read

Share

Short answer

Neither should be deleted by hand — both are held open by Windows and managed for you. Shrink the hibernation file with powercfg /h /size 50, or remove it entirely with powercfg /hibernate off if you never hibernate. Cap the page file through sysdm.cpl → Advanced → Performance → Virtual memory, never zero.

On this page

Run a disk analysis tool on a Windows machine and two files sit near the top of the list that you have never seen in Explorer: hiberfil.sys at maybe 12GB and pagefile.sys at another 8. Together they can be 20GB of a 256GB drive, and the obvious thought is to delete them.

Do not. Both are managed by Windows, both are held open while it runs, and both have supported ways to shrink or remove them that take about a minute. Deleting either by hand — typically by booting from a USB stick — produces anything from a silently recreated file to a machine that will not resume properly.

Here is what each one is for, and what you can actually do about the size.

What the two files do

File Purpose Typical size Safe to delete manually
hiberfil.sys Holds RAM contents during hibernation and Fast Startup ~40% of installed RAM No — use powercfg
pagefile.sys Virtual memory overflow when RAM is short 1–16GB, grows on demand No — resize instead
swapfile.sys Suspends Store apps as a unit 16–256MB No, and not worth it

Both live in the root of C and are flagged as protected operating system files, which is why a normal Explorer select-all never counts them. That is also the main reason a C drive looks full for no apparent reason.

hiberfil.sys: the hibernation file

When you hibernate, Windows writes the entire contents of RAM to this file, cuts power, and reads it back on the next boot. For that to be possible the file must be pre-allocated and contiguous — it cannot be created on demand with the machine half powered down.

Windows sizes it at roughly 40% of installed RAM, which is enough for a compressed image of a typical session. On a 16GB laptop that is about 6.4GB; on a 32GB desktop, around 12.8GB.

Fast Startup uses the same file. When you shut down a Windows 11 PC with Fast Startup enabled, it does not fully shut down — it hibernates the kernel session into hiberfil.sys so the next boot is quicker. Disabling hibernation therefore disables Fast Startup too.

Option A: shrink it

If you want some space back but still use hibernate or Fast Startup, reduce the reservation. Open Terminal (Admin) — right-click Start, choose Terminal (Admin) — and run:

powercfg /h /size 50

The number is a percentage of RAM, and the useful range is 40 to 100. At 50 on a 32GB machine you free roughly 6GB and keep both features. Windows compresses the memory image into whatever you allow; if a session will not fit, hibernate falls back to a normal shutdown rather than failing.

Check the result with:

powercfg /a

That lists which sleep states are currently available, which is also the fastest way to confirm hibernate is still working.

Option B: turn it off entirely

On a desktop that is never hibernated, removing the file is reasonable:

powercfg /hibernate off

The file disappears immediately and the full amount is returned. You lose hibernate, Fast Startup, and — on some machines — hybrid sleep.

To restore everything exactly as it was:

powercfg /hibernate on

This is completely reversible, which is what makes it the safe route. Deleting the file from a recovery environment is not.

pagefile.sys: virtual memory

The page file is where Windows moves memory pages that are not being actively used, freeing physical RAM for what is. It is not a sign that your machine is short on memory — Windows uses it routinely even with RAM to spare, because keeping cold pages on disk is cheaper than keeping them resident.

It also serves two jobs people forget:

  • Crash dumps. Windows writes a blue-screen memory dump through the page file. Without one, you get no dump, and diagnosing a recurring crash becomes guesswork.
  • Committed memory accounting. Some applications — Adobe’s suite and several games notably — reserve large amounts of virtual address space on launch. If the commit limit is too low they refuse to start, regardless of free RAM.

Why “disable the page file for speed” is wrong

It is one of the most persistent pieces of bad advice on the internet, and the reasoning does not survive contact with how Windows works.

Disabling the page file does not make Windows use RAM more efficiently. It removes the safety valve. Instead of paging out an idle background process, the system hits its commit limit and starts killing applications or bluescreening with OUT_OF_MEMORY. On an SSD, paging is fast enough that you will usually not notice it happening at all.

If you are disabling the page file because the machine is slow, the problem is not the page file. Heavy paging is a symptom of insufficient RAM, and the fix is more RAM or fewer open applications. Our guide to finding what is using 100% CPU or disk covers how to tell paging apart from the other causes.

Resizing it safely

If you do need the space, cap it rather than removing it:

  1. Press Win+R, type sysdm.cpl, press Enter.
  2. Advanced tab → Performance section → Settings.
  3. Advanced tab again → Virtual memory → Change.
  4. Untick Automatically manage paging file size for all drives.
  5. Select your C drive, choose Custom size.
  6. Set a sensible floor and ceiling, then click Set and OK.

Reasonable starting points:

Installed RAM Initial size Maximum size
8GB 4096 MB 8192 MB
16GB 4096 MB 8192 MB
32GB or more 2048 MB 8192 MB

Setting initial and maximum to the same value keeps the file contiguous and stops it resizing, which is a mild benefit. A reboot is required before the new size takes effect.

Leave System managed size alone if you are unsure. Windows picks sensibly, and the hand-tuned values circulating in forums are mostly cargo cult from the era of 512MB machines and mechanical drives.

Moving it to another drive

In the same dialog you can select a second drive, give it a custom size, and set C to No paging file. Two caveats:

  • Only do this if the second drive is also an SSD. Moving the page file to a mechanical drive makes every paging operation dramatically slower.
  • Leave a small page file on C anyway — 2048 MB is plenty — so crash dumps still work. Windows can only write a dump to the system drive.

What not to do

  • Do not delete either file from a recovery environment or another OS. Windows recreates them, and in the hibernation case you may land in a state where Fast Startup half-works and the machine resumes into a corrupt session.
  • Do not set the page file to zero on an 8GB machine. This is the setup most likely to produce hard crashes, and it is also the setup where the advice gets given most often.
  • Do not use a “RAM optimiser” to avoid paging. They force working sets out to disk, which is exactly the paging you were trying to prevent, just on a worse schedule.
  • Do not disable hibernation on a laptop unless you are certain you never hibernate and do not care about Fast Startup. The space is rarely worth it.
  • Do not put the page file on a USB drive or SD card. The latency and wear characteristics are wrong for it, and removing the drive while Windows is running will crash the machine.

What you can realistically expect

On a 16GB laptop, powercfg /h /size 50 returns about 3GB with no loss of function. On a 32GB desktop that never hibernates, powercfg /hibernate off returns around 13GB outright.

Page file savings are smaller — capping a system-managed file usually recovers 2–4GB — and the risk of over-tightening it is higher. If you only do one of these, do the hibernation one.

If you need more than that, the larger wins are elsewhere: restore point allocation, update leftovers and the OneDrive cache. All three are covered in how to free up disk space on Windows.

Frequently asked questions

How large is hiberfil.sys supposed to be?
Windows sizes it at roughly 40% of installed RAM — about 6.4GB on a 16GB laptop and around 12.8GB on a 32GB desktop. That is enough for a compressed image of a typical session.
Does disabling hibernation also disable Fast Startup?
Yes. Fast Startup uses the same file — a shutdown with it enabled hibernates the kernel session into hiberfil.sys so the next boot is quicker. Turning hibernation off removes both, which is rarely worth it on a laptop.
Will disabling the page file make my PC faster?
No. It removes the safety valve rather than making Windows use RAM more efficiently. The system hits its commit limit and starts killing applications or bluescreening with OUT_OF_MEMORY. Heavy paging is a symptom of insufficient RAM, not a cause of slowness.
What page file size should I set?
On 8GB or 16GB, an initial of 4096 MB and maximum of 8192 MB is reasonable; on 32GB or more, 2048 MB initial and 8192 MB maximum. Setting initial and maximum to the same value keeps the file contiguous. If unsure, leave System managed size alone.
Can I move the page file to another drive?
Only if that drive is also an SSD — a mechanical drive makes every paging operation dramatically slower. Leave a small page file on C regardless, around 2048 MB, because Windows can only write crash dumps to the system drive.

All Windows guides