Can I Delete Pagefile.sys?

It’s mysterious, hidden, and sometimes very large.

Pagefile.sys is the paging file that contains Windows' virtual memory. You can easily remove it, but you need to understand the ramifications.
Disk & RAM working together.
(Image: copilot.com)

Pagefile.sys is a file (along with swapfile.sys) created by Windows to manage memory usage.

It takes special steps to remove it, but it’s not difficult. I have instructions.

The catch: you probably don’t want to, and even if you do, it won’t make much of a difference unless you’re really low on RAM.

TL;DR:

pagefile.sys

Pagefile.sys is the Windows paging file used to manage virtual memory. It’s used when a system is low on physical memory (RAM). Pagefile.sys can be removed, but it’s best to let Windows manage it for you.

Pagefile.sys

Pagefile.sys is the Windows paging file, also known as the swap or virtual memory file. Virtual memory is disk space used by Windows when it runs out of physical memory, aka RAM.

Pagefile.sys and Swapfile.sys
Pagefile.sys and Swapfile.sys as seen in Windows File Explorer. Click for larger image. (Screenshot: askleo.com)

When programs on the computer use a lot of RAM — perhaps trying to use more than the machine has — some RAM contents are written to the paging file. If the “paged out” memory is needed again, other RAM is written to disk — again in the paging file — and the previously-written information is read back in.

It’s where Windows juggles and keeps track of demands for a lot of memory.

Note that pagefile.sys is a system file. To see the file in Windows File Explorer, the option to “Show hidden files and folders” must be enabled, and “Hide protected operating system files” must be disabled.

Since the file is being used by Windows even when it’s not actively paging memory, you can’t just delete it. It’ll either tell you “permission denied”, “file in use”, or something similar. Extra steps are required.

Ask Leo! is Ad-Free!
Help keep it going by becoming a Patron.

Playing with virtual memory

You may notice pagefile.sys is roughly the same size as your virtual memory settings. That’s a clue.

This leads to our first way to get rid of it: set your virtual memory to zero and reboot. Once you return, Windows will no longer be using the file and will let you delete it. (You may need to use an administrative command prompt to do it.)

If you have enough RAM in your system to handle the amount of memory needed to run all the programs you use at the same time, you may not need virtual memory at all. I have lots of RAM and often run with no virtual memory configured and no pagefile.sys present on my drive.

Note, however, that pagefile.sys will return if you re-enable virtual memory.

Playing with a different operating system

The other approach to deleting pagefile.sys is less useful, but I’ll include it to be complete.

Boot into another operating system and delete the file.

If you boot from a Linux “Live” USB or DVD and explore your Windows hard drive, you’ll find, and should be able to delete, pagefile.sys.

However, as soon as you boot Windows, as long as you have virtual memory enabled, pagefile.sys will return.

Do this

My recommendation? Let Windows manage the file.

Unless you have a reason to adjust your virtual memory settings or know you can run without virtual memory at all, I suggest leaving the settings and pagefile.sys the way they are. Given today’s large hard disks, the amount of space taken by pagefile.sys is generally small in comparison.

Want more tips? Subscribe to Confident Computing! Less frustration and more confidence, solutions, answers, and tips in your inbox every week.

1 thought on “Can I Delete Pagefile.sys?”

Leave a reply:

Before commenting please:

  • Read the article.
  • Comment on the article.
  • No personal information.
  • No spam.

Comments violating those rules will be removed. Comments that don't add value will be removed, including off-topic or content-free comments, or comments that look even a little bit like spam. All comments containing links and certain keywords will be moderated before publication.

I want comments to be valuable for everyone, including those who come later and take the time to read.