It seems that not everyone understands what a paging file is and does.
The OS decides when and how much of an application's working set -- the memory it needs to run -- to keep in memory and how much to put out in a page (swap) file. When an app wants something that's not in memory, that's called a page fault, and the OS brings that chunk of memory back into RAM (probably swapping some other memory out).
If you want to see this in action, open up the task manager, select View|Select Columns, and check the boxes next to
- Memory Usage
- Memory Usage Delta
- Peak Memory Usage
- Page Faults
- Page Faults Delta
- Virtual Memory Size
Look at the Page Faults column (click the heading to sort descending); if your machine has been running for a while (I never turn mine off, and only reboot when absolutely necessary) you will be blown away by the number of page faults. At the moment, Explorer is up around 3.8 million
page faults -- and it's not the biggest memory hog, either.
An interesting thing to do is sort by the PF Delta column and watch what happens; this is the change in the number of page faults between updates. It appears that my update rate is 1 second, and Firefox (in which I'm typing this) is running between 200 and 250 PF/sec, periodically jumping to 4-600, a couple of times to around 1700, and once as high as 5000; watch what happens when you have three windows open, two minimized, and you restore and re-minimize the two that are minimized -- on my system, the PF Delta jumps to 1000-1500 for that second.
What happens when you don't have enough swap? A phenomenon called thrashing, where one part of the app references a block of memory that's swapped out, which then references the first block, which then references the second block, which... It doesn't need to be this direct, but if the same blocks of memory are being cycled in and out over and over and over again, you can guess what happens to your performance.
Running on my XP box, with only 3.5GB of accessible RAM, I typically allocate 3-4x the swap as I have physical memory, and I still
occasionally get a popup notification that my VMEM is running low. On my new Windows 7 box, I have 8GB of RAM, and I believe I gave it 32GB of swap -- on my SSD. I haven't had a chance to test it yet, but typically have at least 40 windows open at any given time. I do a lot of different things, each of which requires one to several applications, some of them major memory hogs (Photoshop and Lightroom, for two examples).
Lest anyone think to tell me to just run fewer apps -- that's both none of your business and totally beside the point. I've been working very successfully in the same manner for over 25 years, and am not inclined to fix something that's not broke when I can just add RAM, swap, and an SSD; and it has nothing to do with whether to use swap or whether to put it on a SSD. The only thing that matters is performance, and...
...according to MS (blogs.msdn.com/b/e7/archive/2009/05/05/support-and-q-a-for-solid-state-drives-and.aspx
), swap files are one thing that you should
keep on your SSD:
Should the pagefile be placed on SSDs?
Yes. Most pagefile operations are small random reads or larger sequential writes, both of which are types of operations that SSDs handle well.
In looking at telemetry data from thousands of traces and focusing on pagefile reads and writes, we find that
In fact, given typical pagefile reference patterns and the favorable performance characteristics SSDs have on those patterns, there are few files better than the pagefile to place on an SSD.
- Pagefile.sys reads outnumber pagefile.sys writes by about 40 to 1,
- Pagefile.sys read sizes are typically quite small, with 67% less than or equal to 4 KB, and 88% less than 16 KB.
- Pagefile.sys writes are relatively large, with 62% greater than or equal to 128 KB and 45% being exactly 1 MB in size.
YMMV, but the first
thing I put on my SSD was my swap. I still have Windows on my HDD -- I just didn't feel that it was worth the space to have Windows start up faster (particularly since in normal use I don't restart very often). I did
, however, put some apps that are notably sluggish on startup on the SSD; they seem to start up much faster, but that could be because of the SSD, the 8GB of RAM, or the quad-core 3.33 GHz processor. :-)
The bottom line is that if you are a relatively light user, in terms of what you have running and what you do with it, you may not need swap, and it doesn't necessarily need to be on the SSD if you do. However, if you're running a lot of memory-hogging apps and editing 750K image files and don't have enough swap allocated -- be prepared to spend a lot of time waiting.