



Comprehensive Guide to the Windows Paging File 495
busfahrer writes "Adrian's Rojak Pot has a nice article about the internals of the Windows paging file. It explains what a paging file is and lists the differences between a swapfile and a paging file. But first and foremost, a large part of the article deals with the various methods of optimizing the Windows paging file, thus yielding a notable performance gain for people who are not overly blessed with RAM."
Defrag first, man. (Score:4, Informative)
I've come across workstations where the paging file is in thousands of fragments. This happens when someone messes with the settings. For instance, they might increase the size of the paging file thinking it'll help to have more. Normally, it's not a bad idea to increase it but if the drive is heavily fragmented, Windows dutifully uses the fragments for the new space.
The only way to fix it is to completely delete (deactivate) the page file, then do a defrag, then re-create the page file (several reboots involved).
That's probably the best way to tune the page file. There, I saved you from having to take the time to read the article.
Re:Defrag first, man. (Score:5, Insightful)
Honestly, I wonder why people take the high and mighty road. The number one problem with computers is people simply don't understand them. The number one way to solve this problem is to educate the user about these little facets of the OS.
The article covers some very basic differences in plain english, and unlike the 'just to do this and leave me alone' attitude, puts the user one step closer to a positive computer experience... a tough thing in today's virus/trojan/adware
Re:Defrag first, man. (Score:4, Insightful)
How could he? 15 posts and the server is toast.
Re:Defrag first, man. (Score:2, Funny)
Re:Defrag first, man. (Score:3, Insightful)
Computers are general purpose devices. They can do many things. With flexibility comes complexity, there's only so much you can do to avoid that.
Re:Defrag first, man. (Score:5, Interesting)
One of the biggest performance helps is to keep the paging file from being fragmented, and I'm not talking about three or four fragments.
The best way to avoid fragmenting the swap file is a method I learned a long time ago, and the author mentions in his article but doesn't talk about much: keeping it on a separate partition. Sure, NTFS doesn't have a swap partition type like Linux does, but I keep a 2 gig partition with a fixed-size swap file on my WinXP box. Set the registry key to ignore "out of space" warnings for that drive, remove read privileges from everybody to that drive, and you basically have an invisible, un-fragmentable swap file that is invincible to user stupidity (I share my computer with my wife, so that last point is important. She does not have Administrator privileges on my box).
Re:Defrag first, man. (Score:5, Funny)
This seems unfair since I'm assuming you have admin privs on her box
Re:Defrag first, man. (Score:5, Funny)
Re:Defrag first, man. (Score:5, Funny)
At least, not after marriage.
Re:Defrag first, man. (Score:4, Funny)
Pity this discussion is strictly academic for the contributers.
Re:Defrag first, man. (Score:3, Insightful)
-nB
Re:Defrag first, man. (Score:5, Funny)
Re:Defrag first, man. (Score:2, Funny)
Signed, the neighborhood peeper.
Re:Defrag first, man. (Score:5, Funny)
Re:Defrag first, man. (Score:5, Funny)
Re:Defrag first, man. (Score:5, Funny)
No, I don't want admin privileges on her box. I don't want to have to deal with daily admin tasks. Instead, I am a power user. Oh yeeeeah!
Re:Defrag first, man. (Score:2, Funny)
This seems unfair since I'm assuming you have admin privs on her box
If she reads that last comment, I'm thinking those rights are gonna get revoked...:)
Re:Defrag first, man. (Score:5, Funny)
Re:Defrag first, man. (Score:2)
A logical strategy, but one that Microsoft strongly deprecates. Don't ask me to explain why, I don't understand either. Maybe their logic is, "We have this clever scheme for an adaptable page file, and if you don't
Re:Defrag first, man. (Score:3, Insightful)
I have gone back and forth between admin and non-admin a few times, more time without admin rights. Some programs have a tough time running, mainly because they want to access stuff they really shouldn't.
I think the problem is the developer culture that built up around Windows, coupled with its changing ideas of how to separate code and data. With Windows XP we essentially have the core idea behind Unix: a /usr and /usr/local directory (Program Files), and a /home directory (Documents and Settings). Howeve
Re:Defrag first, man. (Score:3, Insightful)
Re:Defrag first, man. (Score:3, Interesting)
Man, I hear you! I've written software using the %HOMEDIR% variable, as you suggest, but the software I wrote is multi-user capable. Meaning, that multiple people might use it, and each user has their own set of data.
This works well in the Win98 world, but on XP, if several people share a computer, and somebody logs off the O/S and logs back in as another user, all t
Before the defrag (Score:3, Interesting)
By using 'Diskeeper,' you can also do some additional optimizations besides just defragging it; it's a nice app, though its warnings are overly-dire, and it insists of having something staying in memory all the time, which is irritating.
Re:Before the defrag (Score:5, Informative)
The first one will defragment your Windows pagefile on each boot. And Buzzsaw will defragment recently accessed files in the background, much less intrusive than Diskkeeper. Both are freeware tools.
Or (Score:2)
Kicks the crap out of Windows' built-in defragger, and is much faster too.
Re:Or (Score:5, Informative)
Re:Defrag first, man. (Score:2)
Hardly, unless you're so short on space that you can't fit a copy of the largest fragment. Do a normal defrag, run pagedefrag (from sysinternals), and reboot. Once. Or get a defragger that will do the pagefile -- have it do the registry files and MFT while you're at it. O&O defrag's pretty good, but just about anything is better than the piece of
Re:Defrag first, man. (Score:3, Informative)
Sysinternals does good work.
Re:Defrag first, man. (Score:5, Funny)
Windows paging File... (Score:4, Funny)
Re:Windows paging File... (Score:5, Funny)
Hello?
Voice on phone: No, the white phone.
picks up white phone.
Hello?
PA system: Would Mr. File please pick up one of the white courtesy phones?
(shouting) I've got it!
PA system: Thank you
Re:Windows paging File... (Score:3, Funny)
* Talk to somebody on the white phone?
* Listen to somebody on the white phone?
* Call somebody on the white phone?
swap file vs. paging file (Score:3, Interesting)
Re:swap file vs. paging file (Score:4, Interesting)
Re:swap file vs. paging file (Score:3, Informative)
Re:swap file vs. paging file (Score:5, Informative)
Here [iu.edu] is some more info about paging and swapping under unix
AFAIK a page is an group of memory addresses that are being changed/addressed at the same time.
But I could be mistaken
Re:swap file vs. paging file (Score:2)
Re:swap file vs. paging file (Score:4, Insightful)
Article Text:
We have all been using the terms swapfile and paging file interchangeably. Even Microsoft invariably refers to the paging file as the swapfile and vice versa. However, the swapfile and paging file are two different entities. Although both are used to create virtual memory, there are subtle differences between the two.
The main difference lies in their names. Swapfiles operate by swapping entire processes from system memory into the swapfile. This immediately frees up memory for other applications to use.
In contrast, paging files function by moving "pages" of a program from system memory into the paging file. These pages are 4KB in size. The entire program does not get swapped wholesale into the paging file.
While swapping occurs when there is heavy demand on the system memory, paging can occur preemptively. This means that the operating system can page out parts of a program when it is minimized or left idle for some time. The memory used by the paged-out portions are not immediately released for use by other applications. Instead, they are kept on standby.
If the paged-out application is reactivated, it can instantly access the paged-out parts (which are still stored in system memory). But if another application requests for the memory space, then the system memory held by the paged-out data is released for its use. As you can see, this is really quite different from the way a swapfile works.
Re:swap file vs. paging file (Score:3, Insightful)
If you're talking about losing focus in the window manager sense, it's not possible under linux without some very specific hacks:
If the window manag
Re:swap file vs. paging file (Score:3, Interesting)
I don't think you have any idea how a Linux VM works. There is no "focus" because there is no windows. There are processes and how they are run depends on the scheduler.
Memory management of Windows sucks. There is no question about it. If I don't have a gigabyte page file, I run out of memory (accord
Comment removed (Score:4, Informative)
Re:swap file vs. paging file (Score:3, Informative)
You can then mount this file as a swap partition. You can make a fstab entry to mount this file at boot up as a swap partition.
Please see this URL:
http://enterprise.linux.com/article.pl?sid=05/03/ 0 2/2250257&tid=129&tid=42/ [linux.com]
Re:swap file vs. paging file in Linux (Score:2)
Linux allows multiple swap files.
In the old days on Unix-like systems, it was necessary to have more swap than RAM - as each allocated page of RAM was also allocated a page of swap. That is on longer the case.
At my current job, on lab machines I usually have more RAM than disk space. If I alocate any swap space, I will all
Re:swap file vs. paging file (Score:5, Informative)
Linux only has a paging file (it's still called swap space though). This can either be a hard drive partition, or a regular file.
To make it as a regular file:
dd if=/dev/zero of=some_file bs=1M count=however_big_you_need_it_in_megs
Then:
mkswap some_file
Then:
swapon some_file
You don't need to reboot, and you can add/remove these files at will using swapon/swapoff and the normal filesystem tools.
The 'swappiness' of Linux can also be tuned: since kernel 2.6.0 there has been a proc file
echo 40 >/proc/sys/vm/swappiness
Most 2.6-based distros have some GUI tool that can tweak parameters like this (Fedora certainly does).
Re:swap file vs. paging file (Score:5, Funny)
You sir, are the coolerist. It sweets up the language to add colorfulistic verbing and adverbly structures like the one you buildily made aboverness.
Rockeringly on, dude!
Re:swap file vs. paging file (Score:3, Insightful)
well.. (Score:4, Funny)
Slashdotted already? (Score:5, Funny)
Let Windows manage the pagefile. (Score:3, Informative)
But the best way to optimize the paging file in Win2000 (and later) is to leave it alone. Windows will manage the paging system just fine on its own.
Re:Let Windows manage the pagefile. (Score:2, Insightful)
Re:Let Windows manage the pagefile. (Score:3, Informative)
Sorry, but that's not good advice. There are real issues with fragmentation on NTFS file systems. You can create an empty NTFS partition copy a few files to it, and you can be sure that if the files are larger than 4KB, those files will be fragmented. And if they are of substantial size, the files can be split into dozens of pieces. Moreoever, Windows provide no native ability to defragment metadata on any partiti
FreeRAM (Score:5, Informative)
A free application that you can use to 'pre-page' out pages right before loading up your application. What it does is hog as much RAM as much as it can, forcing the OS to page out any unnessecary applications.
I've seen the standard Explorer + lsass + cwrss + all the svchosts memory footprint go from 80-ish megs to 20. Running this before your game will allow quick load-times and quicker performance.
Re:FreeRAM (Score:4, Informative)
You can change the behavior by modifying the config.trim_on_minimize key (accessible via about:config). See http://windowssecrets.com/041202/ [windowssecrets.com]) for more info on this.
Makes a big difference - no more two second pauses when restoring firefox.
not overly blessed with RAM (Score:5, Funny)
You mean those who's PHBs said the "minimum" requirements were good enough.
Another patent attempt (Score:2, Funny)
Or maybe the will be figthing trying to convince the world that they came up with the idea of a swap space!
Windows' memory mismanagement woes (Score:3, Insightful)
I had to upgrade my laptop from the stock 512 to 1.25GB just because WinXP thrashed the paging file so much. Granted, I multitask like a demon, but it shouldn't take 30 seconds to swap Firefox back in.
Re:Windows' memory mismanagement woes (Score:3, Insightful)
Say, a rule of thumb is, your page file is 2x the size of your physical memory. My mom takes her computer to best buy, and she goes from 128MB of memory to 512MB... typical situation. Now, her windows pagefile will grow accordingly. Or if I manage it for her, I would manually change it. But what if I had to tell her, "well now we have to remove everything on your computer to resize your paritions"?
Re:Windows' memory mismanagement woes (Score:2)
I would chide you for relying on Microsoft's bundled utilities for managing partitions. They're unnecessarily inflexible.
PartitionMagic has been capable of "on-the-fly" partition resizing for ten years now.
Re:Windows' memory mismanagement woes (Score:2)
There are several (both commercial and free) solutions for re-sizing NTFS partitions with no data loss. I'm partial to Partition Expert myself and can only hope that Acronis will release it as a stand-alone Linux app some day.
Re:Windows' memory mismanagement woes (Score:3)
This is something that happened to me on Linux. I found that on a computer with 1 GB RAM, anything more than 256-512MB of swap is almost certainly excessive. Why? Because with so much memory, you should never really be using much swap anyway. When you end using so much is when some program goes mad and decides to allocate all the available memory. And then you'll find that having a
Re:Windows' memory mismanagement woes (Score:3, Insightful)
The size of the page file needs to be the amount of virtual memory you need available minus the amount of physical RAM. So when you increase the RAM, it's appropriate to decrease the size of the page file, unless you are simultaneously planning on using more total virtual memory.
In the Ancient Times, there were systems where the total virtual memory size was equal to the size of the page file.
Re:Windows' memory mismanagement woes (Score:2)
My desktop (dual 7200 rpm hard drives) is slower than my laptop (single 4200 rpm drive) in every way other than the drive. The slight delay as things are swapped never really bothers me there, but the swap latency on a slow laptop drive is nasty.
Re:Windows' memory mismanagement woes (Score:2)
Granted, it would be really nice if MS would do that automatically, but it's still a cheaper solution than adding 750mb of laptop memory.
I'm not sure, but running defrag on the partition weekly might help as well. I'd really like to see MS do automatic drive defrag in the background when the computer isn't being used, or is being used minimally. Th
Re:Windows' memory mismanagement woes (Score:2)
Or Outlook, or any other application for that matter. Yes, my Windows users have that same problem too. They expect me to have a solution as well. I can't see any solution other than switching them over to Linux or OS X. Some I have already moved to OS X and they are happy. Some don't understand why they need to be changed, for some reason they think I can fix it! Are there any ways to stop Windows from running like a lame dog? Of course, this is probab
The other Python (Score:2, Funny)
thus yielding a notable performance gain for people who are not overly blessed with RAM.
She has money, she has a title, she has huge... tracts of RAM!
Re:The other Python (Score:2)
WTF (Score:5, Funny)
Re:WTF (Score:5, Funny)
details of the windows paging file? (Score:3, Funny)
Printer Friendly link (Score:2, Funny)
One of the first paragraphs made me stop reading. (Score:5, Informative)
Whenever the operating system has enough memory, it doesn't usually use virtual memory.
This flies in the face of real world experience. You can have 4 gigs of RAM and nothing but Windows 2000 running and your OS will still use the swap file frequently. Don't believe me? Run Performance Monitor and monitor Memory, Pages/Sec and just click on a few things and you'll see that I'm correct.
Re:One of the first paragraphs made me stop readin (Score:4, Interesting)
Re:One of the first paragraphs made me stop readin (Score:4, Informative)
I don't know why screen savers would stop working, but I bet the developers never planned for the creation of shared memory failing.
Linux pages instead of swaps (Score:2)
In fact, is there any major OS that still swaps?
Does he really believe this? (Score:5, Insightful)
Amazing how they manage to turn everything around as though Microsoft invented the world of computing...
Virtual memory, the term and the implementation have been around long before Microsoft came into existence.
Re:Does he really believe this? (Score:5, Informative)
Virtual memory is the mapping of physical memory pages to a "virtual" memory address using hardware translation tables. This is done so that every application lives in its own private memory space, and cannot interfere with other applications' memory (or the OS's). Basically, this technique of memory isolation keeps user apps from crashing the system or other applications. Virtual memory support has been added to x86 with the release of the 80386 processors and 32-bit flat memory addressing. Of course, virtual memory has been available for years before this on such OS's as DEC's VMS (the Virtual Memory System), IBM's MVS, UNIX, and a bunch of other systems I'm too young to know about.
The misnaming of demand paging was actually started by Apple (continuing their tradition of calling the box a "CPU") for their swap file management (long before MacOS's support for VM in OSX).
Re:Does he really believe this? (Score:3, Interesting)
However, those same virtual tables are used to mark pages as not-present to indicate they are stored on some external storage or do not exist at all. This is also known as a "Virtual memory" feature, so it is not inaccurate to say one of the purposes of virtual memory is to virtualize more memory than is physically available.
Also, the 80286 already added the prot
Re:Does he really believe this? (Score:3, Informative)
Where does it say MS invented this?
MSFT Patents Virtual Memory (Score:2, Insightful)
I couldn't read any more after that.
-Disgusted AC in PA
Another interesting one re: XP and page file (Score:3, Informative)
Virtual Memory in Windows XP [aumha.org] http://aumha.org/win5/a/xpvm.htm [aumha.org]
Windows 98 & WinME Memory Management [aumha.org] http://aumha.org/win4/a/memmgmt.htm [aumha.org]
and there is
How can I optimize the Windows 2000/XP/2003 virtual memory (Pagefile)? [petri.co.il] http://www.petri.co.il/pagefile_optimization.htm [petri.co.il]
CAUTION: Ignorant Article Writer detected (Score:5, Informative)
Take most, if not all, of what the article discusses with a large grain of salt. Everything, from his history (did Microsoft invent demand paging? Hardly) to his terminology is flawed.
Just reading the first 40 comments or so here reveals that VM remains one of those "black magic" areas, where reason is overcome by superstition and people will assert the most ridiculous, irrational and unsupportable things. Regrettably, the contents of this article do nothing to improve the situation.
= Mike
Re:CAUTION: Ignorant Article Writer detected (Score:3, Insightful)
Even the fastest hard disk is currently over 70X slower than the dual-channel PC2700 DDR memory common in many computers. Let's not even start comparing the hard disk with faster RAM solutions like PC3200 DDR memory or...
riiight. excuse me while i laugh and read something else.
What if I am blessed with RAM? (Score:2, Interesting)
Virtual Memory (Score:2, Interesting)
pagefile vs. swapfile (Score:4, Informative)
There is no difference.. He says that swapfiles would swap whole processes. I beg you pardon? Working on whole processes hasn't been the case since 'multiprogramming' on third generation computers (around 1965-1980).
btw, a good program to defrag your Windows page file is PageDefrag [sysinternals.com]
Together with Dirms & Buzzsaw [dirms.com], you can keep your disk defragmented for free. Especially Buzzsaw is nice since it will defragment recently accessed files in the background.
article still doesn't address misconceptions (Score:5, Informative)
I've just finished a project involving reconstructing process images from physical memory, including pages from swap, if available, so I've got a pretty good understanding of this stuff at a very low level.
Misconception 1: Swap-file usage = performance degradation
Yes, it is slower (usually by 3 orders of magnitude, not 1) to access a page (frequently 4K) from disk instead of memory. HOWEVER, effiency dictates that all available RAM be utilized as soon as possible.
For example, in addition to running processes, we also use volatile memory storage to cache file data. Clearly, we want to cache as much as possible. Page replacement policies then become important to determine how much swap space to use. But usually it is much greater than 0, because we've got process image pages that are less frequently used than a lot of file cache pages. So we've gotta remember that data, but we don't wanna waste fast RAM on it.
In other words, isn't it great that we can swap out pages from an unused process to make room for frequently accessed file data? Regardless of how much memory we have, that's a Good Thing.
Misconception 2: Virtual memory = disk space
Virtual memory is a mechanism for translating program-visible addresses to arbitrary storage locations transparently. This doesn't necessarily mean that disk space is used for swapping memory, it means, for example, that 5 processes can simultaneously be accessing address 0x5000, but the actual storage location is different for each. If the system (usually the page address translation facility on the CPU) determines that this address isn't at some location in volatile storage, it will bring in that memory from swap space and possible page out some other data. This is what the article is generally talking about.
I've seen some other questions about pages. There are a couple reasons for treating memory in page-size chunks, where a page is usually in the 1-8k range (4k for x86). First, the page address translation stuff needs to keep data on translations. It must do this in > 1 byte chunks, since keeping translation data on every byte would require way too much storage. Disk I/O and other I/O is frequently done on page-by-page basis for that reason as well as for the sake of performance.
Well, I rambled enough. Just wanted to clear a couple things up.
Another link to article (Score:5, Informative)
44 pages long, full of "sponsored links" (Score:5, Insightful)
Do yourself a favor, give this content-lite article a miss. Make a small partition with ntfsresize, put a fixed pagefile on that partition alone. Works on every single version of windows and it's zero maintenance. Tah-dah.
MS invented everything (Score:5, Interesting)
Back when a 1 MIP, 1MB machine cost $1M, operators became highly skilled at managing workloads. Today everyone just throws oodles of RAM and disk at servers and lets the chips fall where they may , so to speak. It wouldn't be a bad idea to actually put a little thought into matching workloads with machine resources, and pro-actively matching them up by deliberate choice(For example - our company is running a prime-time ad at 9pm that features our URL, maybe that's a good time to shut down the normal file backup that happens then). Chaos theory is not always a good load balancer. But what am I saying, that's as outrageous as asking kids to put their money in the bank instead of buying video games...
Who needs a page file (Score:4, Funny)
The author fundamentally doesn't understand... (Score:3, Informative)
...just to confuse things a bit more (Score:3, Informative)
Then you can put your windows pagefile into linux swap partitions. :-)
disable the page file (Score:3, Interesting)
I have 1GB of memory. This is more than adequate for browsing, games, development, photoshop etc. So, two years ago I disabled the page file after discovering that with 300MB in use, windows was still swapping like crazy (and yes I had all the popular registry hacks applied which should prevent that). So eventually I disabled the page file. The immediate result of doing this is that applications become much more responsive. Suddenly multitasking becomes easy and fast.
Normally when you work with an application for a while, all other applications get swapped to disk. It doesn't matter that you have 700MB of unused, readily available ram. So when you try to alt tab to them, windows spends a couple of seconds moving stuff back into memory. This is very annoying and totally unnecessary. The problem only becomes worse if you start to run some memory intensive programs because windows will swap aggressively then.
Disabling the page file fixes this problem. The only disadvantage of doing this is that when you need more than 1GB it isn't there. This is typically the point where things would get very slow anyway due to swapping. In any case, this doesn't happen very often and is easily resolved by closing some applications. All games are optimized to run well with 256-512 MB. Most games don't use more than that, even if it is available. Office applications and other desktop software rarely use more than 100MB. Photoshop can push the limits but unless you are doing some extreme high resolution photography stuff with it, you will not run into any problems with 1GB. It's actually quite hard to run out of memory. Most things that are infamous for memory usage like ms flight simulator, doom 3, photoshop, vmware, etc all run without problems and without swapping.
If you think about it, swapping is a really lousy solution unless you expect to run out of memory. Disk is many times slower than ram. The reason that you open programs is that you want them ready for action. Swapping them to disk is therefore undesirable. The only reason it would be desirable is if the total amount of memory used by all of your running programs is larger than the amount of memory you have. So if you have 256 MB, swap files are a nice poormans solution to the problem that you don't have enough memory. If you have 1GB you shouldn't have that problem (and if you do, buy another GB).
Re:disable the page file (Score:3, Interesting)
This is your situation, your opinion, and the base of your success.
Other may have different situations and swapping may be better for them. On my Linux box I typically have 160-200 processes running, and I don't need them to be all ready for action. Th
Re:Best advise (Score:2)
Re:optimizing windows (Score:2, Funny)
Re:Rojak Pot? (Score:3, Informative)
The term Rojak Pot, I assume, is meant to portray that this website talks about a wide range of topics.
Re:Nice article, but ... (Score:4, Insightful)
or maybe Multics [multicians.org]
or, more obscure but even earlier Atlas [computer50.org]
UNIX had no virtual memory until late 1980s (Score:3, Interesting)
Re:corrupt (Score:5, Informative)
For example, even under Windows 3.1, the swap file only swapped in chunks of 4/8k. It's just that, on machines that were memory-poor (like we all were way back when), most users had their boxes configured with a 3/1 ratio of swap to real ram, and most of their free real ram then ended up being used to manage the swap file. 2/1 was the sweet spot.
The DOS Shell program, on the other hand, worked by swapping out whole processes, allowing DOS 5.0 and up to appear to multitask.
Pick up a copy of any decent assembler manual for the 2/386 from the early '90s, look for the instructions for swapping pages into ram. It's a hardware function. On a page fault, the cpu then goes through a look-aside buffer (8k worth of pointers each, IIRC, local and global), and then you can map pages of ram in/out as required. Just don't triple-fault, as the cpu would then go out of "enhanced" mode and/or reboot.
Must be a REALLY SLOW day for this to be "news".