|
Page File -
Virtual Memory
A page file is used with computer operating systems that
support virtual memory management. The following article
addresses these concepts. The main objective is to provide
clear descriptions and to provide recommendations for
optimal performance. Due to the complexity of this subject
matter we strongly suggest you research and investigate
areas when necessary. We have provided some links where
applicable.
For a greater understanding of virtual memory, see the
article
here. In general
terms, virtual memory is a method of temporary data storage
used by Microsoft computers. Data is kept on a physical
storage device, the hard disk drive, and then brought to
“main memory” (also known as RAM – random access memory).
In order to do this unique addresses are assigned to data
locations and to areas in memory. The system relies on a
mapping technique in order to sync up one address location
with the other.
A page file is a particular area that holds data,
instructions, or a combination of these two. When data is
required for use, the operating system will take the
required information, and corresponding addresses, and
create a set of units referred to as “pages”. The act of
paging refers to transferring page files between memory and
hard disk storage. The page file is regenerated each time
you start your computer.
By doing this the system takes advantage of having necessary
information on hand in RAM which is faster than accessing it
on physical storage. You might ask, why not keep it in
RAM? The reason is that RAM is “volatile” memory – it is
flushed clear when you turn off your computer. The kinds of
applications you can run and the number of programs you can
run at one time is affected by how much RAM you have on your
system. This is why good software manufacturers include
recommendations on what system requirements are needed to
run a software program.
A Brief History
Virtual memory was first used with the introduction of
Windows 3.x systems. Windows 3.0 came out in May 22, 1990.
It was called a “swapfile” and had a filename of WIN386.SWP
or 386SPART.PAR. Along with all system files, these files
were hidden from view unless you modify the default
settings. Windows 95 makes use of a similar file which can
be accessed in the System settings. Instructions for doing
this are provided below.
You can view hidden files by doing the following:
-
Open Windows Explorer and click the Tools menu.
-
Select Folder Options.
-
Click the View tab and select the Show hidden file and
folders option.
-
Click OK.
When Microsoft released NT operating systems, specifically
Windows 2000 and XP, they introduced the page file: “pagefile.sys”.
The file can be found by default on the drive where the
system files were installed. The evolution of the pagefile
brought improvements. The difference between it and its
predecessor is that page files move portions of an
application process where swapfiles transfer the entire
process. Another distinction is that page files are a
pre-emptive solution where swapping happen when a heavy
demand is placed on the system.
Problems, Faults, and Errors…
Despite the advantages of using a paging system – speed
being the primary one – issues do occur. The most common
relates to page fault errors. Page faults can be valid or
invalid and are caused by a variety of conditions and
factors. To better understand this, we will refer again to
a description of computer functionality. When a program is
running and there are other programs running in the
background, only the information that is actively required
needs to be moved to RAM. Other information in RAM can be
paged out (or swapping can occur depending on what operating
system you are using). When the information that has bee
paged out is required and is not found in RAM an interrupt
is experienced known as a page fault.
When these issues occur the system attempts to resolve it.
If a resolution is found by the system the error is
considered a valid fault error. You will likely not have
noticed anything happening as the system transfers control
back to the running program. However if the page cannot be
found an invalid page error is encountered and you will
likely see an error message. Error messages include:
Windows 3.0: “Unrecoverable Application Error”
Windows 9x: “Illegal operation”
Windows XP: “<Application name> has encountered a problem
and needs to close.”
Windows Vista: “<Application name> has stopped working / is
not responding.”
In more serious situations involving system functioning, a
stop error could result. When this happens you will
experience a blue screen with an error message and
information, also known as a “Blue Screen of Death”.
Alternatively your system could automatically restart as
seen with Windows XP systems where it is set to restart by
default. See our
Stop Error article for more
information.
There
is area in RAM designated as a non-page section as it
contains code that pertains to the system core. If you get
a “Page Fault in Non-Paged Area” message it could mean that
there is damage related to accessing code on an area of a
potentially defective disk drive. It could also mean that a
RAM module is defective. In this latter case, you can
download and run the Memtest86 diagnostic tool:
http://www.memtest86.com/.
Typically invalid page faults are errors occur when an
application is running and the system cannot find the data
in memory. Also, errors occur as a result when the table
with the address mappings or the area related to virtual
memory becomes corrupt. Other possible reasons include:
-
writing to a read-only page
-
attempting to access a page that has a address space that is
not allocated
-
attempting to access a page on standby
-
attempting to write to page that is copy-on-write
-
executing program code that is designated as “no execute”
General protection faults are a common subset of page
faults. While there is a considerable variation of
conditions that can bring on these errors, they are
generally due to virtual memory instability. This is
commonly the result of a shortage of free disk space or
RAM. The page file is used as a type of overflow mechanism
so as to be able to deal with more data than what can be
handled by the existing memory specifications. It requires
storage for the overflow.
Performance and Tweaking
Now you have a general idea of the page file and resulting
faults than can occur. Some of these issues require that
you go online and search for information that will uncover
the contributing factors. A lot of online resources speak
to adjusting the settings of your virtual memory system so
as to enhance the performance of your computer. There are
several considerations for a user to make including: should
I use a page file, where should I place the page file, how
big should it be, how can I make adjustments to the file,
and more. We will cover these in some detail.
Should I use a page file?
You can turn off the page file or set the limits so that it
is effectively not used. Some users may feel that they have
a lot of RAM and that they want to improve performance when
they use an application by only using RAM and not a paging
system. This may be realized if they do not have multiple
applications vying for RAM resources. Sufficient RAM is
necessary beyond what any one application requires.
Microsoft “strongly recommends” to “…not disable or delete
the paging file.”
Where should I place the page file?
The general answer to this is to place it where the most
activity related to your stored data is likely to take
place. For example, if you have only a C: drive than there
is no option – it has to be on this drive. If you have more
than one physical hard disk drive then you want to place the
page file where most of your data resides. The reason for
this relates to “seek times” – the time that it takes for a
hard disk to locate stored data. It takes longer for the
computer to switch from one hard drive to another so it is
best to keep the activity on one hard disk.
Keep in mind that performance gains will occur only when
using a separate physical drive and not by using this
technique with a partitioned drive on the same physical
drive. Microsoft concurs that the page file should be
placed on a different drive than the one with the system
files. They also state that you should not put the file on
a fault-tolerant drive like a RAID-5 drive or a mirrored
volume. Page files do not require fault tolerance and these
drives are typically slower.
How big should the page file be?
There is contradicting information available on the Internet
about how big the page file should be. There are those that
recommend keeping the Initial and Maximum size limits the
same so as to prevent the file from becoming fragmented.
But is fragmentation an issue? If your system is frequently
using more memory than what it can accommodate (in other
words a lack of RAM that is placing heavy demands on the
paging functionality), then occasional defragmentation of
the page file is recommended. However, we recommend that
you consider dealing with the symptoms as mentioned below –
specifically RAM and excessive application use.
Microsoft recommends that you do one of two things with
respect to page size: have Windows select the best page file
size or use set the size limits based on how much RAM you
have on your system. To describe these in detail we will
need more instructions. These directions apply to Windows
XP and may work on other systems. However, you may need to
do more online investigation applicable to your computer
Privileges
As Microsoft points out (http://support.microsoft.com/kb/308417/),
you need to have administrator privileges to make certain
changes to your system settings. With the required
privileges, you can access the System settings by doing one
of the following:
-
Right-click on the My Computer icon on your desktop, select
Properties, and click on the Performance tab
-
Click the Start button, select Settings |
Control Panel | System, and selecting the
Performance tab.
RAM – Determining How Much You Have
To determine the amount of RAM your computer has do the
following:
-
Right-click the My Computer icon on your desktop
-
In the General tab you can see in the section on
“Computer” information related to your CPU and RAM.
-
Make a note of how much RAM is being used.
Changing Page File Settings
With the System Properties dialog open you can access the
page file settings. If you have not been able to access the
System properties as in the last set of instructions you can
do the following:
-
Click the Start button and select Run.
-
In the Open field type: sysdm.cpl
-
Click OK.
To view the page file settings do the following in the
System Properties dialog:
-
Click the Advanced tab.
-
In the Performance section, click the Settings
button.
-
In the Performance Options dialog select the Advanced
tab.
-
In the Virtual Memory section click the Change
button.
Microsoft recommends that you select the “System managed
size” option which means that your computer will determine
how much paging it requires. The other recommendation they
provide is to have an Initial size of 1.5 times your RAM and
a Maximum size of 3 times your RAM. You can use the RAM
notation you wrote earlier and a calculator to come up with
these figures. Before you set these values you need to
decide whether the Microsoft recommendations work for you
and your system.
If you use a lot of RAM – 1 GB or more – you may want to
consider a smaller ratio. We suggest investigating how much
your page file is required based on your regular application
and resource demands. For systems using a swapfile you will
need to refer to the System Monitor and view peak values of
the swapfile in use graph. Follow this link for more
information:
http://www.techarp.com/showarticle.aspx?artno=143&pgno=23
For Windows XP, you will need to use the Task Manager and
refer to the PF Usage graph. Accessing the Task Manager in
XP is rather easy. Try one of these options:
-
Combine the following keys: Ctrl + Shift +
Esc.
-
Right-click in an empty space in the desktop taskbar and
select: Task Manager.
With Windows NT, 2000, XP, or Vista you can do the
following:
-
Press: Ctrl + Alt + Delete.
-
Click the Task Manager button in the dialog that
appears.
Now that you have the task manager open you can get a first
hand view of your page file in action. To view the PF Usage
graph, click the Performance tab in the Windows Task
Manager.
Initial and Maximum Settings
So now that you know how to use the Task Manager you can
adjust the page fault limits and compare the PF Usage. If
you were to set the same values for the Initial and Maximum
values, the page file would be set as a permanent paging
file. By setting these values you have created what is
known as a semi-permanent page file system. The Initial
size (minimum value) determines the size that the operating
system first starts the page file (the permanent portion).
If the system requires it, the page file will be expanded
dynamically to include a size up to and including the
Maximum size set.
The dynamic portion is used when required and is prone to
defragmentation. A defragmented page file, by some
accounts, results in greater seek times and a resulting
performance drop. While there are those that recommend that
you use a permanent page file solution, contrasting opinion
provides a valid point: the page file is likely not read or
written in sequential order. If you are particularly
motivated, you could create a contiguous and permanent page
file with Windows XP by first defragmenting your hard disk
and then setting the two values to the same level.
If your system uses more memory than what is provided for
with available RAM, then you may want to consider
occasionally defragmenting the page file. There are
applications available for this but we recommend other
solutions as described below. You might also want to have
the Initial size set high enough to accommodate all your
required needs so that the dynamic portion is only used as
needed in extreme situations. You may ask why not use a
huge page file? By creating a file that is excessive in
size you will be taking up hard disk space that your system
could be using.
Save and Reboot
If you are not certain you want to use the settings and want
to return to the previous settings, you can click the
Cancel button. When you do want to save the settings
you can click OK and a message appears asking you to
restart the computer for the changes to take effect. Close
all your applications and reboot your system.
Other Considerations
While adjusting the page file to an optimal level is
beneficial, it does by its very use, result in some
degradation of performance. It should not be used if what
is really required is to add more RAM. Your system’s memory
requirements are based on the types and numbers of programs
you are running. You can get a good indication of system
performance from the Task Manager. Optimizing the size of
the page file can provide you with the ability to run
several applications at once and will be useful when using
applications that are resource “hogs” provided you have
sufficient RAM to begin with.
Another consideration is to examine all the resources that
are being used. Often times there are programs that are
running in the background or are automatically launched when
you start your computer. There are software programs that
install to your system and are launched automatically by
default. Some of these can be more than a challenge to
detect and to uninstall or remove. We recommend using a
utility program
such
as RegCure
that has a startup program manager and can also work to
clean up unwanted items in your registry. To remove
unwanted software items that can be malicious in nature –
malware items – we suggest
RegCure.
By providing yourself with the right tools you can protect
yourself from offending programs that attempt to take
control of your system.
In Conclusion
While understanding the purpose of a page file and how it
works in a virtual memory management system is something
each of us can realize even with the information presented
here, it takes effort to determine how best to use it.
While there is so much available data it can feel as though
your head is spinning faster than a data platter, it is best
in the end to diagnose how your system is performing and
what it requires. You need to meet your system needs
through a combination of tweaking the page file, using
sufficient RAM, and taking control of the programs that are
running at any one time. With adjustments to page files –
it is best to gage what your system needs using the Task
Manager and running all the usual applications you normally
would and then try different settings. It may take time but
you can feel confident that you have arrived at an optimal
page file and virtual memory level of performance.
|