Helping people with computers... one answer at a time.

Pagefile.sys is the "paging file" or system file that contains Windows Virtual memory. You can remove it - if you understand the ramifications.

How to delete pagefile.sys. Is it safe to delete?

Sure, you can delete it. It takes some special steps, but it's not really all that difficult.

The problem is that you probably don't want to.

Pagefile.sys is the Windows paging file, also known as the file that Windows uses as Virtual Memory. As I've discussed before, Virtual Memory is simply disk space that Windows uses when it runs out of physical memory or RAM. Some of the contents of RAM are written out to disk to make room for whatever other memory request might have come in. If that "paged out" memory is needed again, some other RAM is written to disk and the previously written information is read back in.

Pagefile.sys is the file where Windows keeps all that:

Windows Explorer showing pagefile.sys

(Note that pagefile.sys is a system file, and thus in order to see the file in Windows Explorer "Show hidden files and folders" should be enabled and "Hide protected operating system files" should be disabled.)

"... Virtual Memory is simply disk space that Windows uses when it runs out of physical memory or RAM."

Now, since the file is being used by Windows, you can't just delete it. It'll either tell you permission denied, or "file in use" or something like that. Extra steps are required.

You'll probably notice that your paging file is roughly the same size as your configured virtual memory settings.

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 thus you can delete it.

If you have enough RAM in your system to handle the amount of memory needed to run the programs you run, you may not need VM at all. That happens to be how I run. (In fact, in researching this article I noticed I had a pagefile.sys when I did not expect one. I'd simply forgotten to delete it after setting my Virtual Memory to zero.)

Pagefile.sys will return if you re-enable virtual memory.

The other approach to deleting pagefile.sys is less useful, but I'll include it for completeness: boot into another operating system, and delete the file.

Quite literally, if you were to boot from a Linux Live CD, and explore your Windows hard drive you'll find, and should be able to delete, pagefile.sys.

We've done exactly what you asked for, but there's a problem.

As soon as you boot Windows, if you have Virtual Memory configured, pagefile.sys will return.

This approach is benign, but I'm guessing this isn't really what you were after.

Ultimately, unless you have some reason to be playing with your Virtual Memory settings, or know that you can run without Virtual Memory at all, I suggest simply leaving the settings, and pagefile.sys, the way they are.

Article C3603 - December 27, 2008 « »

Share this article with your friends:

Share this article on Facebook Tweet this article Email a link to this article
Leo Leo A. Notenboom has been playing with computers since he was required to take a programming class in 1976. An 18 year career as a programmer at Microsoft soon followed. After "retiring" in 2001, Leo started Ask Leo! in 2003 as a place for answers to common computer and technical questions. More about Leo.

Not what you needed?

21 Comments
san
December 29, 2008 8:54 AM

Hello Leo,

You mentioned that you don't have a pagefile.sys file or to put in a different way you have disabled virtual memory. Are there any performance benefits to be achieved by doing so? Given that I have 2GiB physical memory and at most all my processes end up using not more than 500MiB, what would be ramifications of disabling virtual memory altogether?

Regards.

Mostly it just frees up a chunk of disk space (and provides a little security for people concerned about what might be written to their pagefile). If the system isn't using it the performance impact is negligible.
- Leo
30-Dec-2008
AuraliX
December 29, 2008 7:44 PM

Hello leo. im reading your stuff so much time now.
u great. i have a question. from what size of Physical RAM i can disable the VM? casue i my C drive is small and i need that extra space (3069MB - Fixed Size). My PC have 2GB DDR2 800MHz CL5 Physical RAM.
TNX!

There's no one answer - it depends on how you use your computer. If the programs you run regularly use less than your total RAM, then you can probably get rid of VM. If you run programs that end up using more memory than you have RAM, then VM (or more RAM) is required to avoid "Out of Memory" situations at the cost of some speed.
- Leo
30-Dec-2008

sul2005tan
December 30, 2008 2:17 AM

thanks leo, this file is very big 2Gb of my HDD is wasted, my hdd seem good and i can install more program.
Best regard

Dave C
December 30, 2008 8:21 AM

I often defrag and before I do so I set the system to no paging file and reboot, then I defrag and then reset the system to allow Windows to set the paging file size again and it overwrites the previous pagefile,
In this way I feel that I am defragging the area of disk taken up by the page file which otherwise would not be defragged.
I hope that this is a sensible idea.
Just another way of dealing with pagefile.sys rather than just letting it sit there.

David
December 30, 2008 9:18 AM

I seem to remember reading somewhere that either Windows or some programs do expect to "see" some sort of page file on the "C" drive (even if it's only a small one) and I recollect that the recommendation in the article I read was to have a token small one on the "C" drive, even if (as I have done) the main page file is put on a second drive, which is supposed to improve performance.

Mike O'Brien
December 30, 2008 9:21 AM

Hi Leo, re: VM. Have you seen a case where the a desktop's motherboard and HD seem to be incompatable and this results in VM messages about being out of VM no matter how VM is configured? I finally gave up on the friend's computer but it's bugged me ever since. My guess was a computer shop replaced the HD with the wrong type but the situation wasn't one where I wanted to do it again. Really appreciate your site and insight. Thanks for the help....mike

Nope, never seen that. And I'd expect a different more serious error message if there was an incomptibility of some sort.
- Leo
01-Jan-2009

Bradford
December 30, 2008 7:27 PM

Had to use the CD boot once to fix a 98 boot pagefile corrupted error. Worked perfectly.
Occasionally had to delete NT pagefile for tweeking performance. Setting VM to zero is a neat trick I'm glad to know.

Narc
December 30, 2008 11:09 PM

I recall reading in a Microsoftie's blog something about Windows expecting to be able to potentially write, at minimum, the entire contents of RAM to the pagefile -- not in relation to the hibernation file, but rather to some internal Windows processes. I believe the post in question referred to Windows XP specifically, and I don't honestly expect Vista to behave any differently in this regard.

Furthermore, considering that even with 2 GB of RAM in my computer I'm seeing a commit charge (pagefile usage) or 932 MB, I'm loath to suggest its deletion when Windows clearly is using it.

Unfortunately, all I have is a potentially false memory and anecdotal evidence. Plus, I'm certain that Windows will still work without a page file, it's just that I'm of the impression it will not work as well (either BSOD-ing more often, or just performing (paradoxically) worse) as the same install with a page file.

As such, feel free to disregard this comment.

As I mentioned, I run without a page file. Windows XP with 4 gig RAM. It's been as solid as XP gets, and that includes running things like World of Warcraft, Adobe PhotoShop, Sony Vegas (video editting), and more. Often even accidental combinations of the above, just because I forgot to shut something down. :-)

And I don't believe "commit charge" is actually VM usage. As I said, I have no VM, and as I type a commit charge of 1.2gig, which actually matches current RAM usage.

- Leo
31-Dec-2008
Narc
December 31, 2008 9:09 AM

I see! Indeed, checking it again, it seems the commit charge is the sum total of all memory (physical + virtual) usage.

And, what's more, the so-called "Page File Usage" graphs on the Performance tab of Task Manager seem to follow the commit charge, so... in conclusion, I'd like to slap whoever set the labels on those two graphs, 'cause they did it wrong.

Terry Hollett
January 2, 2009 3:46 PM

I can remember having a WinME computer that keep giving me "hard drive C: write errors", which I eventually solved by deleting the page file. Must have been corrupted.

With XP, as I understand it, it may be a security risk since it can have saved passwords, usernames, and other sensitive data.

Here are two ways to have it deleted at shutdown, a clean one will be recreated at start up.

Clearing the Page File on Shutdown

Click on the Start button
Go to the Control Panel
Administrative Tools
Local Security Policy
Local Policies
Click on Security Options
Right hand menu - right click on "Shutdown: Clear Virtual Memory Pagefile"
Select "Enable"
Reboot

For regedit users.....
If you want to clear the page file on each shutdown:

Start Regedit
Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\ClearPageFileAtShutdown
Set the value to 1

http://www.geocities.com/terryhollett2003/

Christopher
January 7, 2009 2:14 PM

I read somewhere that the pagefile is where a memory dump is performed if a system failure would occur, like a bluescreen or the likes. My gaming computer got 12GB ram (64bit OS of course and, yeah, what was I thinking getting that much..). Anyway would there be any reasons like the memory dump example to keep the pagefile, or is it usefulness purely to act as additional ram?

Harshit
February 15, 2009 3:07 AM

Dear,
I tried both & both setting is same as u suggested above. But still i cant decrise the size of pagefile.. Kindly suggest me on my mail ID..

Thanks & regards;

Harshit

scottt
October 20, 2009 8:33 PM

i read on another site to delete pagefile.sys: turn off (VM) reboot then delete pagefile.sys, then turn on (VM) again and 'click' "set". i did this but when i looked in C:pagefile.sys it was the exact size before i deleted it? (3,712,272) did i do something wrong ?

Michael
May 25, 2010 2:23 PM

I just did a search on pagefile.sys. None for the desktop, one for the laptop. Should there not have to be on for the desktop?
Michael
Could this have anything to do with why Hibernation no longer works on my desktop?

Mikey
July 6, 2010 10:06 AM

One use for the delete/recreate cycle is to trade in a fragmented pagefile for a contiguous one. If the old file has grown and fragmented (perhaps as a consequence of increasing RAM), and (through defragmentation) you've got enough clear space for the entire pagefile, this trick will work. Or, you could buy an expensive defragment utility to do this explicitly. Usually a contiguous one-piece pagefile will provide better performance.

Saeed azizieh
August 15, 2011 1:06 PM

I think its volume changes whenever I let my laptop be off for a while about a few hours.
Is it possible? Suppose I have something about 3 gigabyte hidden and I turn the laptop off. After a few hours being left off, its free space turns back.
Is this my illusions?

indnajns
August 18, 2011 4:50 AM

Your second delete suggestion has a great use - when pagefile.sys gets infected with a virus. My antivirus is having issues removing it. Now that I know how to manually remove it, I'll fix the problem myself. Thanks!

Cody S
July 8, 2012 1:16 PM

As a note to deleting from another OS like a Linux Live CD:

This could be a good option for someone who has an infected pagefile.sys. Some viruses can hide out in there, so successfully deleting it from another OS can be useful (even though windows will create a fresh version on next boot)

aaron
October 19, 2012 3:36 PM

i deleted pagefile.sys with cmd and gained 7 gb.

aaron
October 19, 2012 3:40 PM

mine may be infected.notice that i disabled the pagefile

DaveMReed
March 14, 2013 3:30 PM

Thank you again for your very helpful and informative articles!

Comments on this entry are closed.

If you have a question, start by using the search box up at the top of the page - there's a very good chance that your question has already been answered on Ask Leo!.

If you don't find your answer, head out to http://askleo.com/ask to ask your question.