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

URL: https://www.kemptdesk.com/guides/hiberfil-pagefile-sys
Platform: PC
Applies to: Windows 10 and Windows 11
Reviewed: 2026-11-23
Publisher: KemptDesk (https://www.kemptdesk.com), a disk clean-up app for Mac and PC

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.

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](https://www.kemptdesk.com/guides/c-drive-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

| Path | What it is | Safe to delete | What happens if you delete it | How to clean it |
| --- | --- | --- | --- | --- |
| `C:\hiberfil.sys` | Hibernation file, also used by fast startup and hybrid sleep | No | Windows keeps it locked; without it, hibernate and fast startup do not work | `powercfg /h off` removes it; `powercfg /h /type reduced` makes it smaller |
| `C:\pagefile.sys` | Page file (virtual memory) | No | Windows keeps it locked; with no page file, apps can run out of memory and crash dumps are not saved | Virtual memory settings; keep **System managed size** |
| `C:\swapfile.sys` | Paging file for Microsoft Store apps | No | Windows keeps it locked | Leave it to Windows |
| `D:\pagefile.sys` | Page file on another drive | No | Windows keeps it locked while that page file is set | Change 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
```

5. Type `exit` and press Enter.

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

> **Careful:** Microsoft warns that you can lose data if hibernation is off and the power fails while hybrid sleep is on. Without hibernation, hybrid sleep does not work.

### 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.

> **Tip:** If C: is full but another internal drive has space, you can set the page file on that drive in the same dialog. Microsoft says Windows uses the page file that responds first, so a faster drive is used more.

Other system folders on C: have their own safe tools. See [how to shrink WinSxS, Windows.old and SoftwareDistribution](https://www.kemptdesk.com/guides/windows-winsxs-windows-old-softwaredistribution) and [why C:\Windows\Installer must stay](https://www.kemptdesk.com/guides/windows-installer-folder).

## 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

- [How to disable and re-enable hibernation (Microsoft Learn)](https://learn.microsoft.com/en-us/troubleshoot/windows-client/setup-upgrade-and-drivers/disable-and-re-enable-hibernation)
- [Powercfg command-line options (Microsoft Learn)](https://learn.microsoft.com/en-us/windows-hardware/design/device-experiences/powercfg-command-line-options)
- [Compact OS, single-instancing, and image optimization (Microsoft Learn)](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/compact-os)
- [Fast startup causes hibernation or shutdown to fail (Microsoft Learn)](https://learn.microsoft.com/en-us/troubleshoot/windows-client/setup-upgrade-and-drivers/fast-startup-causes-system-hibernation-shutdown-fail)
- [Introduction to page files (Microsoft Learn)](https://learn.microsoft.com/en-us/troubleshoot/windows-client/performance/introduction-to-the-page-file)
- [How to determine the appropriate page file size for 64-bit versions of Windows (Microsoft Learn)](https://learn.microsoft.com/en-us/troubleshoot/windows-client/performance/how-to-determine-the-appropriate-page-file-size-for-64-bit-versions-of-windows)
- [Virtual memory in 32-bit version of Windows (Microsoft Learn)](https://learn.microsoft.com/en-us/troubleshoot/windows-server/performance/ram-virtual-memory-pagefile-management)
- [Troubleshoot Windows Update error code 0x8007000e or 0x800705aa (Microsoft Learn)](https://learn.microsoft.com/en-us/troubleshoot/windows-client/installing-updates-features-roles/error-0x8007000e-0x800705aa-insufficient-virtual-memory)
- [dir command (Microsoft Learn)](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/dir)
- [Windows 8 / Windows Server 2012: The New Swap File (Microsoft Tech Community, Ask the Performance Team)](https://techcommunity.microsoft.com/blog/askperf/windows-8--windows-server-2012-the-new-swap-file/375155)
