May 1, 2008 9:13 PM PDT

Defragging and sizing the Windows page file

An article from earlier today at Download.com about defragging the Windows paging file (Quick Fix: Put your paging file to work) needs some tweaking.

The article suggests that setting the page file Initial Size and Maximum Size to the same number will "avoid serious defragmentation". While this does avoid the paging file growing in size, the file can still be fragmented when it's initially allocated. So, if you're going to do this, you should defrag the hard disk first.

But, not allowing the page file to grow, is a questionable decision. If you make the page file too small, Windows may just stop - think of it like car without gas. If you make the page file too large, you are wasting part of the hard disk.

So, how big should your paging file be? The article says "The paging file should be set to at least 1.5 times the amount of RAM onboard." This is an old wives tale. It is a rule of thumb, not gospel.

The fact is, there is no way to know how large to make the page file. It is a function of the amount of ram available to Windows and the software being used. No single rule can ever be right for everyone. Thus, the page file is designed to grow, should the need arise.


Don't be misled by Task Manager in Windows XP. The Performance tab claims to show the page file usage, but it does not. The screen shot above shows a page file usage of 655MB. The page file on that computer was 300MB at the time.

In fact, the computer where this screen shot was taken, serves to illustrate how poor a rule of thumb can be. It was running Windows XP and had been used for three straight days without rebooting. It had 1.2 gigabytes of RAM. The initial page size was 300 megabytes and the maximum was 550MB. The page file never grows from the initial 300MB allocation. The rule of thumb would have allocated a page file of almost 2 gigabytes. But, of course, your mileage will vary.

So, how do you chose a size for the page file? As Chico Marx once said to Groucho - wrong every time.

That said, I would start by making the initial size the same as the amount of ram in the computer and the maximum size a bit larger. At the end of your computing day, check how big the file is (in Windows XP, the file name is pagefile.sys and, by default, it is in the root directory of the C disk). If it hasn't grown, you're fine. If it consistently grows, then make the initial size larger.

If, after a few days of checking, the page file has not once grown in size, then, for extra credit, you can lower the initial size, assuming you are willing to check it for growth all over again. Changing the initial size requires a reboot.

Page Defrag

But, how can you tell if the page file is fragmented? And if it is, what can you do about it?

Page Defrag is a great little program from Mark Russinovich, formerly of Sysinternals and now with Microsoft. The program is free, portable and from a trustworthy source. While initially designed just for the page file, the current version also defrags the registry, the event logs and the hibernation file. In other words, all the system files that normally can't be defragged.


When you run the program it reports the number of fragments for each of these files. In the best case scenario, shown above, they are all one. To defrag these system files, simply turn on the radio button for "Defragment at next boot". Since these files are always in use by Windows, they can only be defragged before Windows is fully up and running.

Note that according to the documentation, Windows Vista is not supported by Page Defrag.

See a summary of all my Defensive Computing postings.

advertisement
 
Discover unlimited music for the price of one CD a month
Recent posts from Defensive Computing
A word of warning about 'free' public Wi-Fi
Organizing the Start button
A Linux ThinkPad
Beware the innocent web site
The Foxit PDF Reader - fast, free, portable and new
Add a Comment (Log in or register) 9 comments (Page 1 of 1)
by ohsama May 1, 2008 9:41 PM PDT
Wow, this program can defrag registry files, event log and hibernation file SAFELY? I gotta get it.
Reply to this comment
by skurlow May 1, 2008 10:21 PM PDT
PerfectDisk is a great commercial program that can defrag system files like the paging file plus much more!
Reply to this comment View reply
by ruminator May 2, 2008 8:40 AM PDT
I've been running ERUNT, NTRegOpt and Page Defrag as a three pronged defense for years. Works for me. See http://www.abxzone.com/abx_reviews/al/registry.html
Reply to this comment
by SerengetiValley May 2, 2008 9:01 AM PDT
You can defrag the MFT and page file during an offline boot-time defrag with a commercial defragmenter that has the option. Actually, if you want to avoid the hassles of micromanaging the page file size yet want to minimize it's fragmentation, consider one of the newer automatic defragmenters. These are pretty advanced programs that defrag in real-time in the background using idle resources (so other apps are not affected). No need for scheduling defrags and wasting time. More importantly, they automatically manage the the page file and MFT to minimize fragmentation. Google 'fully automatic defragmenter' for more info, as I am unsure of the linking rules here.
Reply to this comment
by a2dcousin May 2, 2008 9:27 AM PDT
Excellent blog. But I'd do what the poster above does and backup first, then i'd turn off anything automatic (even if as simple as choosing right page file size) and choose my options manually.Automatic anything is a recipe for disaster.
Reply to this comment
by SerengetiValley May 7, 2008 12:33 AM PDT
'Automatic anything is a recipe for disaster' is an extreme generalization. Do you also scan each I/O file for viruses manually? Do you search for updates for each installed program manually? A waste of time IMO; a computer is meant to serve the user, and not the other way around lol. Nothing wrong with automatic defrag or any other *properly written* and *safe* automatic software as long as the system fundamentals are solid. If the system is unstable to begin with, then it's a hopeless case regardless of manual or auto. Auto defrag makes life easier so I can get on with using my PC for my work rather than spend time on maintenance. My drives see about 6-10 GB of file modification activity (hundreds of ~10-20 MB files) and manually defragging these regularly is simply not worth it in terms of time and resources. Automatic defrag keeps performance up and drives in good shape, in the background.
Reply to this comment
by a2dcousin May 7, 2008 8:24 AM PDT
Shutting off auto and flyin manual is just following defensive computing guidelines. Risk vs reward; it might take a few minutes more but my computer don't get broken without me even knowing why. In the best of all worlds, everything is "properly written" and "safe" and all systems are stable...but in the real world, none of that holds up. To each his own.
Reply to this comment
by mhinnewyork May 8, 2008 6:13 PM PDT
I agree with a2dcousin - to each his own. If you have a stable system and like the computer doing things for you automatically, that's fine. But some of us prefer the computer do less on the theory that less can go wrong. We prefer stability, or perhaps, *need* stability, even at the cost of manual inconvenience. Be it manually defragging or manually installing bug fixes. Michael Horowitz
Reply to this comment
Powered by Jive Software
  • About Defensive Computing

  • Michael Horowitz is an independent computer consultant and the author of several classes on Defensive Computing. He views Defensive Computing as taking steps, when things are running well, to avoid or minimize the inevitable problems down the road. It's about educating yourself to the level where you can make your own intelligent decisions about keeping your computers and data happy and healthy. If you depend on computers, yet are on your own, without an IT department or nearby nerd, this blog's for you. His personal web site is michaelhorowitz.com.

    He is a member of the CNET Blog Network and is not an employee of CNET.

    Disclosure.

Add this feed to your online news reader
Google
Yahoo
MSN
advertisement
On MovieTome: Your first look at the new JAMES BOND
Visit other CNET Networks sites: