Any benefit or detriment from removing a pagefile on an 8 GB RAM machine?

80,986

Solution 1

TL;DR version: Let Windows handle your memory/pagefile settings. The people at MS have spent a lot more hours thinking about these issues than most of us sysadmins.

Many people seem to assume that Windows pushes data into the pagefile on demand. EG: something wants a lot of memory, and there is not enough RAM to fill the need, so Windows begins madly writing data from RAM to disk at this last minute, so that it can free up RAM for the new demands.

This is incorrect. There's more going on under the hood. Generally speaking, Windows maintains a backing store, meaning that it wants to see everything that's in memory also on the disk somewhere. Now, when something comes along and demands a lot of memory, Windows can clear RAM very quickly, because that data is already on disk, ready to be paged back into RAM if it is called for. So it can be said that much of what's in pagefile is also in RAM; the data was preemptively placed in pagefile to speed up new memory allocation demands.

Describing the specific mechanisms involved would take many pages (see chapter 7 of Windows Internals, and note that a new edition will soon be available), but there are a few nice things to note. First, much of what's in RAM is intrinsically already on the disk - program code fetched from an executable file or a DLL for example. So this doesn't need to be written to the pagefile; Windows can simply keep track of where the bits were originally fetched from. Second, Windows keeps track of which data in RAM is most frequently used, and so clears from RAM that data which has gone longest without being accessed.

Removing pagefile entirely can cause more disk thrashing. Imagine a simple scenario where some app launches and demands 80% of existing RAM. This would force current executable code out of RAM - possibly even OS code. Now every time those other apps - or the OS itself (!!) need access to that data, the OS must page them in from backing store on disk, leading to much thrashing. Because without pagefile to serve as backing store for transient data, the only things that can be paged are executables and DLLs which had inherent backing stores to start with.

There are of course many resource/utilization scenarios. It is not impossible that you have one of the scenarios under which there would be no adverse effects from removing pagefile, but these are the minority. In most cases, removing or reducing pagefile will lead to reduced performance under peak-resource-utilization scenarios.

Some references:

dmo noted a recent Eric Lippert post which helps in the understanding of virtual memory (though is less related to the question). I'm putting it here because I suspect some people won't scroll down to other answers - but if you find it valuable, you owe dmo a vote, so use the link to get there!

Solution 2

Eric Lippert recently wrote a blog entry describing how Windows manages memory. In short, the Windows memory model can be thought of as a disk store where RAM acts as a performance-enhancing cache.

Solution 3

As I see from other answers I am the only one that disabled page file and never regreted it. Great :-)

Both at home and work I have Vista 64-bit with 8 GB of RAM. Both have page file disabled. At work it's nothing unusal for me to have few instances of Visual Studio 2008, Virtual PC with Windows XP, 2 instances of SQL Server and Internet Explorer 8 with a lot of tabs working together. I rarely reach 80% of memory.

I'm also using hybrid sleep every day (hibernation with sleep) without any problems.

I started experimeting with it when I had Windows XP with 2 GB of RAM and I really saw the difference. Classic example was when icons in Control Panel stopped showing itself one after one, but all at once. Also Firefox/Thunderbird startup time increased dramatically. Everything started to work immediately after I clicked on something. Unfortunately 2 GB was too small for my applications usage (Visual Studio 2008, Virtual PC and SQL Server), so I enabled it back.

But right now with 8 GB I never want to go back and enable page file.

For those that are saying about extreme cases take this one from my Windows XP times.
When you are trying to load large Pivot Table in Excel from an SQL query, Excel 2000 increases its memory usage pretty fast.
When you have page file disabled - you wait a little and then Excel will blow up and the system will clear all memory after it.
When you have the page file enabled - you wait some time and when you'll notice that something is wrong you can do almost nothing with your system. Your HDD is working like hell and even if you somehow manage to run Task Manager (after few minutes of waiting) and kill excel.exe you must wait minute or so until system loads everything back from the page file.
As I saw later, Excel 2003 handles the same pivot table without any problems with the page file disabled - so it was not a "too large dataset problem".

So in my opinion, a disabled page file even protects you sometimes from poorly written applications.

Shortly: if you are aware of your memory usage - you can safely disable it.

Edit: I just want to add that I installed Windows Vista SP2 without any problems.

Solution 4

You may want to do some measurement to understand how your own system is using memory before making pagefile adjustments. Or (if you still want to make adjustments), before and after said adjustments.

Perfmon is the tool for this; not Task Manager. A key counter is Memory - Pages Input/sec. This will specifically graph hard page faults, the ones where a read from disk is needed before a process can continue. Soft page faults (which are the majority of items graphed in the default Page Faults/sec counter; I recommend ignoring that counter!) aren't really an issue; they simply show items being read from RAM normally.

Perfmon graph http://g.imagehost.org/0383/perfmon-paging.png

Above is an example of a system with no worries, memory-wise. Very occasionally there is a spike of hard faults - these cannot be avoided, since hard disks are always larger than RAM. But the graph is largely flat at zero. So the OS is paging-in from backing store very rarely.

If you are seeing a Memory - Pages Input/sec graph which is much spikier than this one, the right response is to either lower memory utilization (run less programs) or add RAM. Changing your pagefile settings would not change the fact that more memory is being demanded from the system than it actually has.

A handy additional counter to monitor is PhysicalDisk - Avg. Queue Length (all instances). This will show how much your changes impact disk usage itself. A well-behaved system will show this counter averaging at 4 or less per spindle.

Solution 5

I've run my 8 GB Vista x64 box without a page file for years, without any problems.

Problems did arise when I really used my memory!

Three weeks ago, I began editing really large image files (~2 GB) in Photoshop. One editing session ate up all my memory. Problem: I was not able to save my work since Photoshop needs more memory to save the file!

And since it was Photoshop itself, which was eating up all the memory, I could not even free memory by closing programs (well, I did, but it was too little to be of help).

All I could do was scrap my work, enable my page file and redo all my work - I lost a lot of work due to this and can not recommend disabling your page file.

Yes, it will work great most of the time. But the moment it breaks it might be painful.

Share:
80,986

Related videos on Youtube

Jason
Author by

Jason

Updated on September 17, 2022

Comments

  • Jason
    Jason over 1 year

    I'm running Windows 7 on a dual core, x64 AMD with 8 GB RAM.

    Do I even need a page file?

    Will removing it help or hurt performance?

    Would it make a difference if this is a server or a desktop?

    Does Windows 7 vs. Windows 2008 make a difference with a page file?

  • Pyrolistical
    Pyrolistical almost 15 years
    Do you mean this? blogs.technet.com/markrussinovich/archive/2008/11/17/… If so, his advice is lame. He says page file will increase performance because if would give more ram to other apps. True, if you don't have much ram. But if you have more than enough, page file is never faster.
  • Mathieu Chateau
    Mathieu Chateau almost 15 years
    it was in a sysinternal video with Salomon. It had something to do with kernel page pool
  • Masterfu
    Masterfu almost 15 years
    Prepare for a rush of upvotes--this was mentioned in the podcast (blog.stackoverflow.com/2009/06/podcast-59). +1 from me.
  • Gulzar
    Gulzar almost 15 years
    +1 . .
  • Michael Haren
    Michael Haren almost 15 years
    I'd go a bit further and not cap the page file. That's not really improving things. Let windows do it...they know better.
  • LaikaN57
    LaikaN57 almost 15 years
    For Jeff and Joel: it rhymes with "ducks"
  • Martin Beckett
    Martin Beckett almost 15 years
    On Solaris it was/is even more involved. The swap file is mirroed in a ram disk like tmpfs so the memory is always almost full - but it is apparently provable that this is the optimal strategy.
  • Sam
    Sam almost 15 years
    I've had my pagefile disabled, and regretted it the moment I really used my memory. So be happy you have more memory than you need.
  • John Fouhy
    John Fouhy almost 15 years
    I have long believed that, instead of allowing Windows to manage my page file size, I should set it to a fixed amount (e.g. min 2GB, max 2GB), because letting it grow and shrink can cause fragmentation problems. Is that good thinking, or should I follow your first line and let Windows handle everything?
  • LaikaN57
    LaikaN57 almost 15 years
    John, my own preference is for system-managed. But you should read the article I linked (Pushing the Limits: Virtual Memory) closely and see how you feel about this. Note carefully the parts where Mark used Testlimit to force the pagefile to grow, creating that stairstep graph. There is a few seconds of delay while the PF grows, so if you have memory demands that come on VERY quickly, this could create issues for you. I believe situations where this is a problem to be corner cases, pretty uncommon.
  • hyperslug
    hyperslug over 14 years
    @quux, what about support.microsoft.com/kb/889654: "as more RAM is added to a computer, the need for a page file decreases. If you have enough RAM installed in your computer, you may not require a page file at all, unless one is required by a specific application." Am I misreading something or is this a different/special case?
  • LaikaN57
    LaikaN57 over 14 years
    hyperslug, see Sam's answer below (from Jul 22); it gives a great example of why a paging file can sometimes be useful even when you have a lot of available memory. Nothing in my answer above is meant to suggest that you must always have a paging file! Only that when you remove it, you may not envision every circumstance your computer will ever encounter. And the lack of pagefile could one day bite you on the butt, as it did Sam.
  • LaikaN57
    LaikaN57 over 14 years
    Ha! That said, thank you, hyperslug, for the KB889654 link. It is good to see MS saying in clear print that the pages/sec counter is nearly useless, which I have been saying for quite some time. Do follow their advice to monitor pages input and pages output to get a better handle on whether you need a pagefile. Or better yet - leave the defaults in place. I've never seen a situation where an unused pagefile lowered performance; on the other hand, as Sam shows, having an unavailable pagefile can lead to nasty surprises.
  • AngryHacker
    AngryHacker over 14 years
    I love it how everyone is saying "Microsoft has spent many hours thinking about this problem, so don't mess with it", yet completely ignore real world experiences. I've had the paging file disabled since XP and never regretted it. It's like the computer got an injection of awesome.
  • Admin
    Admin over 14 years
    Don't you mean total memory potentially available? Most paging systems keep snapshot page copies.
  • Scott Pedersen
    Scott Pedersen over 14 years
    you should save more often :D in order to minimize the damages
  • Rich Seller
    Rich Seller over 14 years
    One quibble, it is preemptively
  • Sam
    Sam over 14 years
    easy to say, when saving does take several minutes, this is a pita.
  • PP.
    PP. over 14 years
    You can't post an "answer" when you have no idea: I have a Windows Vista 32-bit laptop with 4GB of RAM and I put it into standby all the time. Can you at least restrict yourself to supplying answers to questions you actually know answers to?
  • mpbloch
    mpbloch about 14 years
    Do your XP virtual machines also have pagefiles disabled?
  • mpbloch
    mpbloch about 14 years
    Just tried to use Media Player Classic to load a 6GB mkv file. It ran me out of my RAM and pagefile memory. Went back to VLC pretty quick. +1 for the "you never know what you'll run into". Eventually MPC crashed and my RAM was restored, but what if you get a DLL in third party software with a memory leak? You will have a lot more mileage if you have some disk-backed memory to help you out.
  • SeeR
    SeeR about 14 years
    @mpbloch No, because I always set VM memory to the lowest required by it's usage.
  • Philip
    Philip almost 14 years
    It's pretty standard practice to disable paging on servers that iSCSI boot, paging over the SAN would be noticable slow. You just really have to watch your memory usage, and stay away from the max.
  • fencepost
    fencepost over 13 years
    The ASP.NET error strikes me as perhaps being a 32-bit issue, but if the number you provided is correct (399556608 = 399,556,608) then the error is correct - ~400MB is approximately 5% of 8GB.
  • cgp
    cgp about 13 years
    +1, simple for the Mark Russinovich link. It's worth pointing out that win7 even pops up a notification to point that you will not be able to "trace down system problems" if you disable the swap file.
  • user541686
    user541686 over 12 years
    Let's say you don't use more than 50% of your RAM. Why can't the backing store be somewhere else in RAM, instead of on a hard disk? (If that 50% limit is exceeded, then the OS could switch to using the disk as a backing store, obviously. But why should it do so from the very start?)
  • David Schwartz
    David Schwartz over 12 years
    @Mehrdad: Because you don't want to have to keep 50% of your RAM free. Sure, you could do that, but you would lose 50% of the physical RAM you could be using as a disk cache for active data. Free RAM is a sign of inefficiency, it's like FedEx trucks at a depot instead of on the road. It means you're not moving as much freight as you could because you're spending too much time loading and unloading.
  • David Schwartz
    David Schwartz over 12 years
    Plus the point, what's the good of having 8GB if you have to live in constant fear of actually using it?!
  • user541686
    user541686 over 12 years
    @David: So you're assuming that memory that is otherwise unused is always used for caching data? That's a nice idea, but I've never seen Windows cache 2 GiB of data. (I have 6 GiB of RAM, and I rarely even use 2 GiB of it at once, except for when I occasionally create 4-GiB RAM disks. Never do I notice Windows caching anything on the order of gigabytes -- it's usually a hundred or so megabytes max, after which it starts writing to the disk like crazy.)
  • David Schwartz
    David Schwartz over 12 years
    @Mehrdad: I'm not sure why you see that, but what I see is that pretty much all available RAM is used as cache. For example, the box I'm on right now (Win 7, 64-bit, 8GB of RAM) is doing typical desktop work. 385MB is free, 5,440MB is cached. This is as it should be. Free RAM is wasted RAM. You might as well hold data that's also on disk -- it can help (if you wind up needing it) and it can't hurt (you can always throw it away when RAM is scarce).
  • user541686
    user541686 over 12 years
    @David: Not sure why it's different, but I have Win 7 x64 too. (I'm talking more about what I've noticed practically, rather than what the system is reporting -- I haven't checked that in a while.) And yes, while I agree that free RAM is wasted RAM, it wouldn't be wasted if it was used for duplicating information the same way the page file would, right?
  • LaikaN57
    LaikaN57 over 12 years
    @Mehrdad - keeping RAM 'backing store' in another RAM location would essentially nullify the point of having a backing store in the first place. It exists so that the RAM can be cleared (quickly!) and used for something else, should another demand come up.
  • LaikaN57
    LaikaN57 over 12 years
    Also it should be pointed out that pagefile writes are 'lazy' anyway - IIRC they do not take priority over most userland disk i/o. So I'm curious what you think you will actually gain by limiting or removing the pagefile and/or moving backing store to RAM?
  • user541686
    user541686 over 12 years
    @DavidSchwartz: Right, but at what point, exactly, do you have "enough" RAM? It seems like you would make the same claim no matter how much RAM the host has... which seems a little unreasonable to me. At some point RAM has to be sufficient, right? quux: You would free up unnecessary disk space, and also avoid unnecessary I/O (which, even though prioritized, still affects other things somewhat).
  • LaikaN57
    LaikaN57 over 12 years
    Until the time when RAM is as cheap and plentiful as disk space, I can see few scenarios where I would be so certain of all future usecases in the life of the system that I could guarantee pagefile never being needed. The disk usage is cheap compared to the RAM cost. And I don't think the additional, low priority IOs saved are going to matter that much in a properly sized server. In short, when you're down to eliminating pagefile because the system needs that disk space or IO, your system is already almost certainly undersized/overloaded.
  • user541686
    user541686 over 12 years
    @quux: No, I can't guarantee that either. So when I have to compile Chromium (for example), I just turn on my pagefile. In all other times, I turn off my pagefile. No need to be certain about anything -- a little control on the user's part can go a long way.
  • LaikaN57
    LaikaN57 over 12 years
    @Mehrdad - Well, to each his own. I just wonder if and how you'd quantify the actual performance benefit you're getting when you disable pagefile. Aside from hard disk space, that is - which you clearly have to spare anyway, since you can turn it on at will. Anyway, this is turning into a discussion thread which SF is not well suited to, so I will stop here. Cheers.
  • Stoph
    Stoph over 12 years
    You do have issues but you don't notice them, consider how an increased memory load can slow down simultaneous request. Enabling the page file makes such moments more snappier...
  • LaikaN57
    LaikaN57 over 12 years
    @romkyns Actually, I did. Read it again?
  • mafu
    mafu over 12 years
    The "keep at least a small pagefile" seems a little weird to me since it is not clear how Windows is going to use it. For instance, it might thrash it even more than a bigger pagefile that offers more space - I'm guessing, but as long as there is no reliable source on this I would consider the small pagefile advice possibly harmful and recommend a standard practice instead.
  • mafu
    mafu over 12 years
    What PP tried to say: The hibernation process uses a file separate from the swap file, so this is not an issue in this case.
  • Mas
    Mas over 11 years
    Doesn't this imply that with SSDs, it might be better to turn off paging (excluding the case where you actually run out of RAM)? Thrashing wouldn't be so bad because reads from an SSD are really fast.
  • LaikaN57
    LaikaN57 over 11 years
    SSD reads are fast, but memory reads are faster. Pagefile lets you put what's frequently in use, into memory for speedier access. SSD does help on bringing old paged-out stuff back into RAM, which is clearly a good thing. But if SSD were a clean replacement for RAM, then we'd be phasing RAM out and going SSD entirely, right? See this e7 blog entry with some stats that help dispel the idea that pagefile will wear out an SSD: goo.gl/Q4nI
  • LaikaN57
    LaikaN57 about 10 years
    Pyrolistical, it's probably far too late for you to see this, but turn your statement around and phrase it as a question: When does pagefile slow anything down? A good answer to that would prove your theory.
  • Eric Duncan
    Eric Duncan almost 10 years
    Software Engineer, Photoshop (amatur) Artist and avid gamer here for the past 20 years. I disabled the Paging file back in XP, and have never looked back. At this moment, I have two VMs running while playing BF4 while answering this SF question with 12 tabs open in Chrome. Given, I have always maxed my ram (8, 12, 16, 32, etc) - this particular machine has 32 GB. Instant access and no thrashing of my precious SSDs. The only issues I've had is with Visual Studio and bad code that creates memory leaks, using 20GB of ram! Not a pagefile need - better coding needs!
  • speeder
    speeder almost 8 years
    Found this thread by accident. But I decided to comment here, I am thinkong of disabling pagefile on WIndows 8, due to the third paragraph on quux awnser. I have a Windows 8 laptop with very slow HDD, Windows behaviour of filling the RAM with cache, and preemptively writing stuff to pagefile, made the system VERY slow and unresponsive, I wanted an alternative beside disabling the pagefile, and asked on SuperUSer about it, but sadly got no decent awnsers. superuser.com/q/1066289/27885
  • speeder
    speeder almost 8 years
    Can I disable the mechanism described in your third paragraph on Win7/8/10 ? In my country HDD laptops are still common, and that preemptive writing to pagefile make them horribly slow, because of near-constant unecessary I/O, the only "solution" I found is disable pagefile, but that has all the issues pointed out before.
  • LaikaN57
    LaikaN57 almost 8 years
    speeder: I'm not aware of a way to disable the Memory Manager's use of pagefile as backing store. But I think pagefile writes are FAR less constant than you imagine. Use perfmon's 'Memory\Page Writes\Sec' counter to monitor them on your system, and see for yourself.
  • Jerad Rose
    Jerad Rose over 7 years
    @fencepost good catch - must have read that as kb for some reason. weird
  • Damon
    Damon over 6 years
    We all are save happy if you use more complex software, but sometimes, a "crash" ends up aligning with "Oh crap, I haven't saved in a while."
  • Mike Holdsworth
    Mike Holdsworth about 6 years
    Yes, "ImageHost.org is closed"
  • Shawn Eary
    Shawn Eary about 3 years
    @MichaelHaren - "...they know better..." - That's why SuperFetch used to work so "well" right??? Also, now that it's 2021 and my Mechanical HDs are seriously slow by today's standards, I'm wondering if a Win 10 Swap file would have a negative impact on the life of a newly purchased SSD.