A. Any program that runs on an Intel 386 or later system can access up to 4GB of RAM, which is typically far more memory than is physically available on a machine. To make up for the missing physical memory, the OS creates a virtual address space, known as virtual memory, in which programs can see their own 4GB memory space. (This virtual address space consists of two 2GB portions--one for the program and one for the OS.) The OS is responsible for allocating and mapping to physical RAM those parts of the program or memory that are currently active.
To work around a machine's physical RAM limitations, a local file known as the pagefile stores pages (in 4KB increments) that aren't in use. (One installation can have multiple pagefiles.) When a program needs to access a page from the pagefile, the OS generates a page fault that instructs the system to read the page from the pagefile and store it in memory. Because disks are much slower than memory, excessive page faults eventually degrade performance. A computer's RAM consists of two sections. The first section, the non-paged area, stores core OS information that's never moved to the pagefile. The second section, the paged area, contains program code, data, and inactive file system cache information that the OS can write to the pagefile if needed.
Although the discussion so far might lead you to believe that Windows stores only active code and data (plus the core OS) in physical RAM, Windows actually attempts to use as much RAM as possible. Often, the OS uses RAM to cache recently run programs so that the OS can start these programs more quickly the next time you use them. If the amount of available free RAM on your computer is low and an application needs physical RAM, the OS can remove from RAM pages of memory used to cache recently run programs or move non-active data pages to the pagefile.
So, if you have a lot of RAM, you don't need a pagefile, right? Not necessarily. When certain applications start, they allocate a huge amount of memory (hundreds of megabytes typically set aside in virtual memory) even though they might not use it. If no pagefile (i.e., virtual memory) is present, a memory-hogging application can quickly use a large chunk of RAM. Even worse, just a few such programs can bring a machine loaded with memory to a halt. Some applications (e.g., Adobe Photoshop) will display warnings on startup if no pagefile is present.
My advice, therefore, is not to disable the pagefile, because Windows will move pages from RAM to the pagefile only when necessary. Furthermore, you gain no performance improvement by turning off the pagefile. To save disk space, you can set a small initial pagefile size (as little as 100MB) and set a high maximum size (e.g., 1GB) so that Windows can increase the size if needed. With 1GB of RAM under normal application loads, the pagefile would probably never need to grow.
If you want to prevent Windows from moving any core OS kernel or driver files to the pagefile, perform the following steps:
Start a registry editor (e.g., regedit.exe).
Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management registry subkey.
Set the DisablePagingExecutive registry entry to 1.
If you want to determine how much of the pagefile is actually being used, you can download Bill James' various pagefile utilities, which are available at this Web site. Among these tools is a WinXP-2K_Pagefile.vbs script that tells you the current and maximum pagefile usage.
Reader Comments
”because Windows will move pages from RAM to the pagefile only when necessary”
Not true according to my experience. Windows 95 and 98 only used the pagefile when necessary. But Windows NT, 2000, XP does use it even when NOT necessary. (And probably also Windows 2003.) The OS seem to free RAM by moving pages to the pagefile even if there is large amounts of unused RAM! I usually se about 20-60MB of the pagefile used for this. Is there a way to tell Windows to ONLY move data to the pagefile when needed?
And another related question…
In Windows 95 and 98 there was a setting in system.ini which you could use to specify the maximum size for the filecache. This was very useful because it stopped Windows desktop, i.e. explorer.exe + loads of dll-files being swapped out when doing a normal copy of a large file.
Example:
Computer with 512MB of RAM.
Windows uses 100MB of RAM after startup.
I copy a 1GB file.
Windows uses all available RAM, 512MB for filecache, causing almost everything but non-paged pool being swapped out to the pagefile.
After file copy, trying to open a folder in explorer takes ages to load!
However, if you reserve 128MB of RAM by setting system.ini to:
[vcache]
MinFileCache=4096
MaxFileCache=393216
Now you don’t have any delays double-clicking folders, opening start-menu, or whatever you do on the Windows desktop.
Is there a way to specify how large the filecache may grow in Windows NT, 2000, XP and 2003?
Best regards,
Daniel Mukka Nyberg
Daniel Mukka Nyberg -March 18, 2004
Ahhh, but even a small (32MB) page file can seriously slow down your machine, because ANY program doing any kind of disk access (virtual paging included) has to wait ages while the many disk accesses occur, I proved it! My WinXP Pro PC, with 1.5GB of RAM, runs MUCH faster with no paging file, I VERY rarely see low memory warning from TaskInfo, even when running many large applications (http://www.iarsn.com/).
IMHO Microsoft should fix Windows so that it doesn't need to make the huge number of unnecessary paging operations, as seen in TaskInfo.
Infernoz -March 20, 2004
Excellent bit of information. Most commendable and definitely a public service. Thanks,
Joe Vazquez -April 10, 2004
I just upgraded my workstation to 1GB RAM and had the same question concerning Pagefile.Sys. Now that I know to leave Pagefile alone, how come Windows XP does not clear the RAM once a program has exited? I was using Nero 6 Deluxe & when I was done it still maintained the 700MB of Ram that it initially allocated.
Steven -July 08, 2004
Steven said: "Now that I know to leave Pagefile alone, how come Windows XP does not clear the RAM once a program has exited? I was using Nero 6 Deluxe & when I was done it still maintained the 700MB of Ram that it initially allocated."
Windows frees up RAM only when needed and, when available, uses keeps code for recently closed programs in RAM until another program requires that memory space. It does this so that if, say, you closed Nero and wanted to reopen it, it will load very quickly, because it's still sitting there in RAM. Try it: open a program that normally takes a few seconds to load, close it, then repoen it. It'll load much faster the second time. However, if you open it, then close it, then open another program that uses a large amount of RAM, then close it and reopen the first one, it won't be quite so quick.
The bottom line with the Windows pagefile is this: let the system deal with it - it knows what it's doing!
Anonymous User -April 03, 2005
Daniel has it right on.
I currenly have 100+ MB free physical memory, yet currently application A is running with 13MB/20MB physical/virtual memory usage and generating 200+ page faults per second! Nothing else is generating page faults. Wth is this application not entirely in physical memory?? And this is WinXP. The constant paging is using a good fraction of the CPU cycles, making any other application that tries to page really slow, and who knows what constant stress it puts on the HD.
I agree that having a pagefile is a good idea, but WinXP just doesn't do it right. Virtual memory has been a performance issue with Windows for years.. how come it still does obviously wrong things? If people have objectively measured performance gains from removing the page file, then that itself indicates a poor implementation.
Anonymous User -April 10, 2005
I have 1.2 gigs of RAM and a 200 meg set pagefile on my XP box and still got the "low virtual memory" error. I checked the task manager and see that I have almost 900 megs of free memory but my Office 2003 apps have swallowed up nearly the entire 200 meg pagefile and wants more!!! I'm pretty PO'ed because I'm using a laptop with a slow Hard Drive so I'd rather XP not page out at all, especially if I've got over 800 megs of memory sitting on it's *** doing nuthin. I've tried disabling the pagefile altogether but that will only result in my applications complaining that I don't have a pagefile. Any suggestions (besides increasing my pagefile, I mean). Plz e-mail me tienbo2000@yahoo.com. Thanks.
Anonymous User -May 04, 2005
My PC has 1GB of RAM so I disabled Windows paging file and it worked wonderfully. I think it is only suitable for simple applications such as email checking, web browsing... like me. If you are a developer, a designer or a power user I recommend not to disable the paging file. However, why don't you try it and compare the difference?
Anonymous User -May 27, 2005
I have a pc with 1 1/2 gigs of ram and it runs awesome without a page file, i also have a pc with 1 gig of ram without a pagefile and that, although it pushes it- sometimes i only have 80-150 mb of ram free- runs much better than with a paging file.
Anonymous User -June 22, 2005
I have 1.5 gigs of RAM and I really only use my main machine for computer games such as Battlefield 2, Call of Duty, World of Warcraft and Half Life 2, page file set to off and never once have I ever gotten a page file error. Of course this is only with games, if I were a programmer, or graphic artist, I would most likely use a page file.
Anonymous User -June 29, 2005
I have always understood Virtual Memory was to improve performance, not hinder it. Now I have some thinking to do.
I have a new Intellistation Z Pro IBM workstation with 8GB's of RAM and 2 400GB hard drives, with an 80GB boot drive. I was going to set virtual memory to at least 4GB, but now I am not sure?
I also have an Lacie 400GB external hard drive. Do I bother with virutal memory on an external, removable device?
Thanks.
Cal
Nivlac -July 06, 2005
I am a developer, and I have my page file disabled. Windows XP uses the page file even when not necessary, so with it disabled, you have no wait time to shut processes down.
Anyone know how to disable Photoshop warning about a page file? Maybe a registry setting?
Anonymous User -August 15, 2005
1G RAM, 2CPUs XEON, WinXP, pagefile disabled. Pagefile IS an evil for machines with REALLY lots of RAM. I'm a programmer, so running compilation in two copies of VisualStudio + an instance of virtual Linux (coLinux) compiling something + actively used normal supporting programs like several copies of FAR manager / HIEW / etc. Everything works fine, still never saw memory usage above half of gig. For Win2K I couldn't disable that stupid no pagefile warning although this OS runs OK as well.
As it might seem from the article, Windows aims to allocate 4G for every application but it's not true. First of all, only 2G not 4G, as since WinNT OS upper memory is never available to applications. Second, only loaded image and commited stack is allocated by default, all other memory is still unavailable (hence neither paged nor mapped) until application explicitly allocates some or exceeds its initial stack size. Even if application allocates say 400M, it's still possible just to map available physical memory without necessarily referring to disk paging mechanism.
So, my vote by thumbs down to pagefile with lots of RAM.
Anonymous User -August 17, 2005
i'm interested in trying out software based RAM disks: software that creates a virtual drive that is super fast (it's actually RAM), and using it to host the pagefile. has anyone tried this ?
bob
2005.duaribulima@gmail.com
Anonymous User -August 19, 2005
Apparently this is not a good thing. Since it obviously reduces the amount of ram avaliable so it starts using the page file earlier, meaning you would need a vast amount of ram for this to work.
Anonymous User -August 21, 2005
Daniel is correct.
Microsoft's claim that the pagefile is used only "when the memory in use by all the existing processes exceeds the amount of RAM available" is blatantly untrue. Let's just call it a lie.
WinXP tries to send ALL inactive paged memory to the pagefile. It is fairly agressive in what it considers 'inactive'. Don't believe me? Lauch a few large applications (but make sure you still have plenty of physical RAM), leave your computer for 30 minutes, and come back and check the pagefile. If you don't want to figure out which counter to use in Performance Monitor, here is a great little tool: http://billsway.com/notes%5Fpublic/WinXP%5FTweaks/
As you can see, WinXP will shove as much of your running application to the pagefile as possible. Usually half of my allocated RAM is offloaded to the pagefile even with hundreds of free MB of physical RAM. I have had particular trouble with memory intensive applications, but I see preformance degradation across the board. My 1GB system might as well be a 128MB system, given the way WinXP thrashes my hard drive with pagefile swaps. My total memory usage rarely goes above 500MB.
Bottom line: if you have a lot of memory (and it is so cheap these days) turn off your pagefile for a dramatic performance boost.
One warning: You are more vulnerable if you encounter a nasty memory leak, as you have no pagefile to buffer you. So programmers and beta testers may want to keep their pagefile.
-Neil
nlaslett@ndi.org -April 23, 2006
Neil (immediately above) is correct. I have become really tired of reading the saaaaame incorrect advice parroted over and over again, especially in the MS Windows XP newsgroups. "Don't you dare disable the page file ... You need it ... Windows XP won't use it unless it's necessary."
Lies, damned lies, all of it. Tell me, why, on a system with 2-GB of RAM, do I see WinXP put hundreds of MB into the page file, while leaving many hundreds of MB of physical RAM unused? Why does that RAM ... NEVER get used? Why, when I had my page file enabled, did I so often encounter drastic slowdowns as the page file was being read? Why did I see a serious performance improvement when I disabled the page file altogether?
I mean, come on... Think about it: Microsoft recommends using 1.5 times the amount of RAM installed as the minimum page file size. Does this make ANY sense to you? Think about it. You have more RAM, so wouldn't you need a SMALLER page file, and vice-versa?
None of their advice makes sense; this article's advice doesn't make sense; and if you have enough memory, disable the page file.
Free CDs Offer Fundamental Content for IT Pros Are you up to speed on the latest technologies and solutions? Don't miss out on your chance to get up to speed quickly on fundamental, in-depth information on some of the hottest topics in our library of content.
Let Your Users Reset Their Own Passwords: Free Download Try a 30 day free trial of Desktop Authority Password Self-Service – it provides an easy-to-use, robust system for allowing users to reset their own forgotten passwords or locked accounts.
Get Windows IT Pro & Mark Minasi’s Favorite Power Tools Guide Order Windows IT Pro now and get "More of Mark Minasi's Favorite Power Tools"--a in-depth guide to the most useful Windows commands --FREE with your paid order! Subscribe today, and save 58% off the cover price!
Deep Dive into VMware vSphere, eLearning Series Join John Savill to explore the major functionality capabilities of the vSphere virtualization platform, including identification of the changes from ESX 3.5.