KemptDesk

Can you delete hiberfil.sys, pagefile.sys and swapfile.sys in Windows?

For PCWindows 10 and Windows 11Reviewed 23 November 20268 min read

Quick answer

Do not delete C:\hiberfil.sys, C:\pagefile.sys or C:\swapfile.sys by hand: Windows uses them and keeps them locked. To remove the hibernation file, run powercfg /h off as administrator. To make it smaller and keep fast startup, run powercfg /h /type reduced. Leave the page file on automatic size unless you have a clear reason to change it.

On this page
  1. Where the files are
  2. What each file does
  3. Which of these files you can remove
  4. How to turn off or shrink the hibernation file
  5. How to change the page file size
  6. Risks of turning off the page file
  7. How KemptDesk handles this
  8. Questions
  9. Sources

These files are often among the largest single files on a full system drive. They are one part of what to delete when the C drive is full.

Where the files are

All three are hidden system files in the root of a drive, usually the Windows drive:

  • C:\hiberfil.sys: the hibernation file. Microsoft says it is in the root folder of the drive where Windows is installed.
  • C:\pagefile.sys: the page file. Windows can keep one page file in the root of each drive you choose.
  • C:\swapfile.sys: a smaller paging file that Windows uses for apps from the Microsoft Store.

File Explorer does not show them by default. To see them and their sizes, open Command Prompt and run this command. It only lists files and changes nothing:

cmd
dir C:\*.sys /a

The /a switch makes dir show hidden and system files as well.

What each file does

hiberfil.sys

When the PC hibernates, Windows saves a copy of the system memory to hiberfil.sys on the disk and turns off. Microsoft says the computer cannot hibernate if the file is not there.

The same file is used by two other features. Hybrid sleep stores a copy of memory in the file. Fast startup, which is on by default, signs you out and puts the system into hibernation when you shut down, so the next start is quicker.

The size depends on the amount of RAM in the PC. Microsoft's hibernation article says it is about the size of the installed RAM; Windows can also set it as a percentage of RAM, so on many PCs it is smaller.

pagefile.sys

Microsoft describes the page file as an optional, hidden system file. Windows moves modified memory that is used rarely from RAM to the page file, so RAM is free for the data in active use.

The page file also raises the commit limit, which is RAM plus all page files. Programs can use memory only up to that limit. If they reach it, Microsoft says the system can freeze, crash or fail in other ways.

When Windows crashes with a stop error, it writes a crash dump through the page file or a dedicated dump file. Without one of them, Windows cannot save the dump that helps find the cause.

By default the page file is System managed. Microsoft says it can grow, when memory use is high, up to three times the RAM or 4 GB, whichever is larger, but no more than one eighth of the drive.

swapfile.sys

swapfile.sys is a second paging file that Windows uses for apps from the Microsoft Store. Windows manages it, and it has no setting of its own.

Which of these files you can remove

PathWhat it isSafe to deleteWhat happens if you delete itHow to clean it
C:\hiberfil.sysHibernation file, also used by fast startup and hybrid sleepNoWindows keeps it locked; without it, hibernate and fast startup do not workpowercfg /h off removes it; powercfg /h /type reduced makes it smaller
C:\pagefile.sysPage file (virtual memory)NoWindows keeps it locked; with no page file, apps can run out of memory and crash dumps are not savedVirtual memory settings; keep System managed size
C:\swapfile.sysPaging file for Microsoft Store appsNoWindows keeps it lockedLeave it to Windows
D:\pagefile.sysPage file on another driveNoWindows keeps it locked while that page file is setChange the drive's page file in Virtual memory settings

How to turn off or shrink the hibernation file

Decide first:

  • Turn hibernation off if you never use Hibernate, you do not need fast startup, and you want the most space back.
  • Use the reduced type if you want fast startup but do not use Hibernate. Microsoft notes that turning fast startup off is not recommended.
  • Keep it as it is if you hibernate a laptop to save battery, or if you use hybrid sleep.

Turn hibernation off

This removes hiberfil.sys. Hibernate, hybrid sleep and fast startup stop working until you turn hibernation on again.

  1. Select Start and type cmd.
  2. Right-click Command Prompt and select Run as administrator.
  3. When User Account Control asks, select Yes (or Continue).
  4. Type this command and press Enter:
cmd
powercfg /h off
  1. Type exit and press Enter.

To turn hibernation on again later, run powercfg /h on the same way.

Make the hibernation file smaller

A reduced hibernation file supports fast startup, but not the Hibernate option. The reduced file is smaller than the full one, because it holds only what fast startup needs. In an administrator Command Prompt, run:

cmd
powercfg /h /type reduced

If you set a custom size for the file before, Windows treats it as a full file. Microsoft's steps are to give the size back to Windows first, then set the type:

cmd
powercfg /h /size 0
powercfg /h /type reduced

To check the result, run powercfg /a. It lists the sleep states this PC can use and the reasons why others are not available.

How to change the page file size

Leave the page file on automatic size in most cases. Microsoft's advice for update errors caused by low virtual memory is to turn automatic management back on. To see or change the setting:

  1. Select Start, type sysdm.cpl and press Enter. System Properties opens.
  2. Select the Advanced tab. Under Performance, select Settings.
  3. In Performance Options, select the Advanced tab. Under Virtual memory, select Change.
  4. To let Windows choose, select Automatically manage paging file size for all drives.
  5. To choose yourself, clear that checkbox, select a drive, then select Custom size, System managed size or No paging file, and select Set.
  6. Select OK and restart the PC.

A smaller page file gives back space, but it lowers the commit limit. Microsoft says page file size depends on each system's peak memory use and crash dump setting, so it cannot be given as one number for everyone.

Other system folders on C: have their own safe tools. See how to shrink WinSxS, Windows.old and SoftwareDistribution and why C:\Windows\Installer must stay.

Risks of turning off the page file

Some people turn the page file off on a PC with a lot of RAM. Microsoft says a page file might not be needed for memory in that case, but these risks stay:

  • Programs can fail, and Windows can freeze, when memory use reaches the commit limit, which is lower without a page file.
  • Windows cannot save a full crash dump without a page file or a dedicated dump file.
  • Some programs and services require a page file. Their own documentation says so.

How KemptDesk handles this

KemptDesk treats pagefile.sys, hiberfil.sys and swapfile.sys in the root of a drive as System. They are Protected: never selected and never removed by any page. Space Lens shows each one with a short explanation. For the hibernation file it says to run powercfg /h off as administrator. For the page file it points to System > Advanced > Performance > Virtual memory. For swapfile.sys it says that Windows manages it. KemptDesk does not run powercfg and does not change power or virtual memory settings; use the steps above.

Questions

Is it safe to delete hiberfil.sys?

Not by hand; Windows keeps it locked. Run powercfg /h off as administrator and Windows removes it, but Hibernate, hybrid sleep and fast startup stop working.

Should I turn off the page file if I have 32 GB of RAM?

Usually no. Microsoft says a large amount of RAM can be enough for memory use, but a page file or dedicated dump file is still needed for crash dumps, and some programs require one. Leave it on System managed size.

Why is pagefile.sys so big?

A system-managed page file grows when memory use is high and to fit the crash dump setting. Microsoft lists the upper limit as three times the RAM or 4 GB, whichever is larger, and no more than one eighth of the drive.

Does powercfg /h off turn off fast startup?

Yes. Fast startup puts the system into hibernation at shutdown, and it needs the hibernation file. Use powercfg /h /type reduced to keep fast startup with a smaller file.

What is swapfile.sys and can I delete it?

It is a paging file that Windows uses for Microsoft Store apps. Windows manages it and keeps it locked, so leave it in place.

Sources

See what is safe to delete on your computer

KemptDesk scans your disk, explains every folder and selects only what apps can rebuild. The scan is free and cleans up to 500 MB. No account.

Then pay once from $59 or yearly from $9.99 for the first year until 31 December 2026, then $24.99. One license covers Macs and PCs. See plans