Over the course of six major Windows operating system versions, a lot has been written about the page file. The page file is designed to virtually extend the amount of physical memory in the computer, thus allowing the operating system to run more applications than it actually has enough physical memory to handle. Some articles will tell you that a permanent page file offers better performance than an operating-system-managed dynamic page file, while other articles will tell you just the opposite. Articles that advocate a permanent page file all espouse different opinions as to values that should be used as the minimum and maximum sizes.
And, of course, you're told that adding more physical memory to the system will reduce Windows' reliance on the page file. Even then, you're told that your mileage will vary depending on the types of applications you run as well as the size and amount of data you're processing.
Now here we are running Windows XP, purportedly the most robust and efficient Windows operating system ever. Even so, there’s still a lot of debate over how to get the best performance out of the page file. Regardless of whether the page file is dynamic or permanent, if it’s too small, applications might run short on virtual memory. If it’s too large, you might be wasting disk space that could be used for other purposes. In either case, you can reconfigure the page file settings in order to promote faster and more efficient computing.
So how do you know if the page file in your Windows XP system is offering you the best performance possible? Unfortunately, there's not a lot of readily available information on this aspect of the page file topic.
Of course, there are several native Windows XP tools that you can use to keep an eye on your page file to see how it's being used, but the analysis presented by these tools is not as straightforward as you might expect. To begin with, you can find a lot of valuable information about the page file’s behavior on the Performance tab of the Task Manager. However, the page file statistics reported here are folded in with physical memory in such a way that it's a bit difficult to decipher the exact size of the actual page file.
You can also get detailed information on page file usage by monitoring its activity via System Monitor. However, it too gets a bit vague when it comes to reporting actual page file size. Now, don’t get me wrong—both the Task Manager’s Performance tab and the System Monitor are great tools. But wouldn’t it be great if Windows XP came with a tool that would show you exactly how large the page file actually is at any point in time in relation to the amount of hard disk space that Windows XP is configured to set aside for the page file? That way, you could tell at a glance whether your current page file is offering you optimal performance. Unfortunately, such a tool doesn’t exist.
However, I’ve discovered that you can access very concrete information on the actual size of the page file from the Windows Management Instrumentation (WMI) Win32_PageFileUsage class that is built into Windows XP. This WMI class is designed to present the actual run-time state of the page file on a Win32 system.
Once I discovered this fact, I developed a script that uses features from Windows Script Host and VBScript to access the Win32_PageFileUsage WMI class, and created a tool I call the Page File Data Logger, which logs the actual size of the page file usage at regular intervals. It then enters the data into an Excel spreadsheet and automatically creates a bar chart of the page file usage.
Download our Page File Data Logger tool and Win32_PageFileUsage demonstration script
You can download our Page File Data Logger and Win32_PageFileUsage demonstration script by following this link or by clicking on the Downloads link in the navigation bar at the top of this page. TechRepublic and TechProGuild have many useful documents, templates, and applications available for download, so be sure to check out our other offerings.
The PageFileDataLogger.vbs and Win32_PageFileUsage.vbs files have been zipped together to increase download speed. The files have also been renamed PageFileDataLogger.txt and Win32_PageFileUsage.txt respectively because many antivirus programs filter out VBS files. Rename the PageFileDataLogger.txt file to PageFileDataLogger.vbs and the Win32_PageFileUsage.txt file to Win32_PageFileUsage.vbs before you use either script.
In order to use the Page File Data Logger tool, you must have Excel 2000 or 2002 installed on your computer. The script may run with Excel 97; however, I was unable to test it with this version of Excel. (If you’re running Excel 97, please post a message in this article's discussion and let me know if the script works with this version of Excel.) Furthermore, the Page File Data Logger tool is specifically designed to work in Windows XP. It will also work in Windows 2000 and may work in Windows NT 4.0. However, it won’t work in Windows 95/98/Me.
The WMI Win32_PageFileUsage class
As you may know, WMI is the Microsoft extension to the Distributed Management Task Force (DMTF) Web-based Enterprise Management (WBEM) initiative. It provides a set of interfaces for access to components that provide management capabilities to an enterprise as well as open up a vast amount of detailed system information. Using WMI, you can query a wide variety of system information, such as the Win32_PageFileUsage class.
Now, as I mentioned, the Win32_PageFileUsage class is designed to present the actual run-time state of the page file on a Win32 system at any point in time. The Win32_PageFileUsage class contains the following properties:
- AllocatedBaseSize: Actual amount of disk space allocated for use with this page file
- Caption: Short description of the object—a one-line string
- CurrentUsage: Amount of disk space currently used by the page file
- Description: Description of the object
- Name: Name of the page file
- InstallDate: The date on which the page file was created
- PeakUsage: Highest use page file
- Status: Current status of the object
- TempPageFile: Indicates whether the page file is a temporary page file
To see the type of information the Win32_PageFileUsage class can provide, take a moment to download and run the demonstration script shown in Listing A. In lines 1 thru 4, this script taps into WMI on a local computer and accesses the Win32_PageFileUsage class. Then, in lines 5 through 15, the script uses a For…Loop structure and the Wscript.Echo command to present the values exposed by each of the properties in individual dialog boxes.
Listing A: The Win32_PageFileUsage.vbs demonstration script
- On Error Resume Next
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
- Set colItems = objWMIService.ExecQuery("Select * from Win32_PageFileUsage",,48)
- For Each objItem in colItems
- Wscript.Echo "AllocatedBaseSize: " & objItem.AllocatedBaseSize
- Wscript.Echo "Caption: " & objItem.Caption
- Wscript.Echo "CurrentUsage: " & objItem.CurrentUsage
- Wscript.Echo "Description: " & objItem.Description
- Wscript.Echo "InstallDate: " & objItem.InstallDate
- Wscript.Echo "Name: " & objItem.Name
- Wscript.Echo "PeakUsage: " & objItem.PeakUsage
- Wscript.Echo "Status: " & objItem.Status
- Wscript.Echo "TempPageFile: " & objItem.TempPageFile
Once you run this demonstration script, you’ll see that the AllocatedBaseSize, CurrentUsage, and PeakUsage properties provide specific information on the actual size of the page file on your system. With this in mind, let’s take a look at the Page File Data Logger tool.
Installing the Page File Data Logger tool
Once you download the PageFileDataLogger.zip archive file, manually installing the tool on your hard disk is easy. Create a folder anywhere on your hard disk and name it something like PFDataLogger. Then, unzip the PageFileDataLogger.zip archive file and copy the file PageFileDataLogger.vbs to the folder. (Remember, you'll need to rename the PageFileDataLogger.txt file to PageFileDataLogger.vbs.) You can create a shortcut to this file on your desktop if you want.
Launching the tool
Now that you’ve downloaded and installed the tool, let’s take a look at how it works. To launch the tool, just double-click the PageFileDataLogger.vbs file. When you do, you’ll momentarily see a splash screen as the utility loads. You’ll then see the first dialog box, shown in Figure A, which gives you the choice of running the tool in background or interactive mode.
|While the Page File Data Logger tool is designed to run in the background, you can run it interactively.|
Running in interactive mode
If you choose to run the Page File Data Logger tool in interactive mode, the tool will instantly log the current page file data and then display the dialog box shown in Figure B. This dialog box shows you the values of AllocatedBaseSize, CurrentUsage, and PeakUsage for the page file and the time those values were recorded. The Page File Data Logger tool will then wait for you to decide your next step.
|In interactive mode, the tool will show you the current page file values and the time they were recorded.|
At this point, you can continue working, and the tool will drop to the background. At any time, you can activate the dialog box and click the Yes button. When you do, the tool will log the current page file data and then display the dialog box again. You can repeat these steps at whatever interval you want. For example, you can log the current page file data after you load an application or perform any operation that you suspect will change the actual size of the page file.
When you’re finished with your interactive page file logging operation, just click No. You'll then be prompted to view a bar chart of the page file usage. More on this bar chart in a moment.
Running in background mode
If you choose to run the tool in background mode, the tool will display the dialog box shown in Figure C. This dialog box informs you that, by default, the tool will automatically log the page file data at 15-minute intervals. This will give you four log entries for every hour that you work on your computer. If that sounds satisfactory, just click No.
|If you want to use a longer or shorter interval, you can change the default logging interval.|
If you want to use a longer or shorter interval, click Yes, and you’ll see the dialog box shown in Figure D, which prompts you to enter a new interval. Be sure that you enter your new interval value in minutes. For example, if you want to log page file data every half hour, type 30 in the text box.
|You must enter your new interval value in minutes.|
When you click OK, the Page File Data Logger tool will record the new interval value, log the current page file data, and then quietly go to sleep until the time interval elapses. When it does, the tool will log the current page file data and then display the dialog box shown in Figure E. This dialog box reminds you that the tool is still running in the background and asks if you want to stop the logging operation.
|At the beginning of every time interval, the tool will ask if you want to stop logging.|
When this dialog box appears, Windows will play the default sound associated with the Asterisk program event to alert you. The Page File Data Logger tool will then wait for a response for five seconds. If you don’t respond, the tool will automatically close the dialog box and go back to sleep until the time interval elapses again.
When you’re finished with your background page file logging operation, just click Yes. When you do so, you’ll be prompted to view a bar chart of the page file usage, as shown in Figure F.
|Once you finish the logging operation, you’ll be prompted to view the bar chart.|
The bar chart
As the tool works, it stores the page file usage data in a CSV (comma separated values) file. Once you terminate the logging operation, the tool saves and closes the file, and then opens it again in Excel. The tool then automates Excel’s chart creation operation and displays a chart like the one shown in Figure G.
|Once the tool completes its logging operation, it can display the results in an Excel chart.|
As you can see, the chart uses the AllocatedBaseSize as the maximum value. In the case of my example Windows XP system, the AllocatedBaseSize is 766 MB. This particular chart shows the page file data gathered at 30-minute intervals over the course of a workday. On this particular day, the actual page file usage just barely broke 100 MB and then only toward the end of the day.
As you look at the example chart, you can see that on this particular day, the AllocatedBaseSize of 766 MB for the page file is definitely overkill. However, as in any monitoring operation, I’d recommend that you use the Page File Data Logger tool for several days in order to compare the results and look for trends or patterns.
If this were to represent a typical day as far as computer usages goes, I’d have to say that the 766 MB is wasting disk space that could be used for other purposes. I’d then recommend that you reduce the page file to a more appropriate size. Not only would this recover wasted disk space, but it would also reduce operating system overhead, since Windows wouldn’t have to spend time unnecessarily managing such a huge file.
On the other hand, if the bar chart indicated that the page file was almost maxed out all day long, I’d recommend that you enlarge the page file to a more appropriate size.
Greg Shultz is a freelance Technical Writer. Previously, he has worked as Documentation Specialist in the software industry, a Technical Support Specialist in educational industry, and a Technical Journalist in the computer publishing industry.