3. Fine-Tuning Virtual Memory
Your computer uses virtual memory to extend the amount of
available RAM by writing physical memory (RAM) to disks through a
process called paging. With paging,
Windows 7 writes a set amount of RAM, such as 1,834 MB, to the disk as a
paging file, where the operating system can access it from the disk when
needed in place of physical memory.
Windows 7 writes paging files to disk drives as a file named
pagefile.sys. Windows 7 creates an
initial paging file automatically for the drive containing the operating
system. By default, other drives don’t have paging files, so you must
create these paging files manually if you want to use them. However, in
most instances, you won’t need to put a paging file on multiple disks,
as doing so won’t necessarily boost performance.
As with many other aspects of performance, Windows 7 does a much
better job than its predecessors do of automatically managing virtual
memory. Typically, Windows 7 will allocate virtual memory at least as
large as the total physical memory installed on the computer. This helps
to ensure that paging files don’t become fragmented, which can result in poor system
performance.
You can also manually manage virtual memory. If you do this,
you’ll typically want to use a fixed virtual memory size. You fix the
size of the virtual memory by setting the initial size and the maximum
size to the same value, and this in turn prevents fragmentation of the
paging file.
NOTE
In most cases, I recommend setting the total paging file size so that it’s twice the physical
RAM size on the system. For instance, on a computer with 1,024 MB of
RAM, you would ensure that the “Total paging file size for each drive”
setting is at least 2,048 MB.
If your computer has more than 4 GB of RAM, however, you’ll
probably want to set the paging file size so that it’s approximately
1.5 times the size as the physical memory. For instance, on a computer
with 6,144 MB of RAM, you would ensure that the “Total paging file
size for each drive” setting is at least 9,216 MB.
To achieve optimal performance, you may want to consider using a
fixed minimum of 1 times the RAM and a fixed maximum of either 2 times
or 1.5 times the RAM. Fixing the size of the paging file in this way
ensures that Windows allocates sufficient file space to the page file
initially and doesn’t need to repeatedly increase the size of the
paging file as you start using programs on your computer.
You can manually configure virtual memory by completing the
following steps:
In the Control Panel, click the System and Security category
heading link.
Click System. In the left pane under See Also, click
Performance Information and Tools.
Under Tasks, click “Adjust visual effects.” This opens the
Performance Options dialog box.
On the Advanced tab, click Change to display the Virtual
Memory dialog box shown in Figure 3. The following information
is provided:
- Drive [Volume Label] and Paging File Size (MB)
Show the current configuration of virtual memory. The
dialog box lists each volume with its associated paging file
(if any). The paging file range shows the initial and maximum
size values of the related paging file.
- Paging file size for each drive
Provides information on the currently selected drive and
enables you to set its paging file size. “Space available” indicates how much space is
available on the drive.
- Total paging file size for all drives
Provides a recommended size for virtual RAM on the
system and shows the amount currently allocated.
By default, Windows 7 manages the paging file size for all
drives. If you want to configure virtual memory manually, clear the
“Automatically manage paging file size for all drives”
checkbox.
In the Drive listbox, select the disk volume you want to work
with.
Select “Custom size” and then enter an initial size and a
maximum size.
Click Set to save the changes.
Repeat steps 6–8 for each disk volume you want to
configure.
Click OK. If prompted to overwrite an existing pagefile.sys file, click Yes.
If you updated the settings for a paging file that is
currently in use, you’ll see a prompt explaining that you need to
restart the system for the changes to take effect. Click OK.
Click OK twice to close the open dialog boxes. You’ll see a
prompt asking if you want to restart the system. Click
Restart.
You can have Windows 7 automatically manage virtual memory by
following these steps:
In the Control Panel, click the System and Security category
heading link.
Click System. In the left pane under See Also, click
Performance Information and Tools.
Under Tasks, click “Adjust visual effects.” This opens the
Performance Options dialog box.
On the Advanced tab, click Change to display the Virtual
Memory dialog box shown in Figure 3-20.
Select the “Automatically manage paging file size for all
drives” checkbox.
Click OK twice to close the open dialog boxes.
4. Fine-Tuning Data Execution Prevention
Data Execution Prevention (DEP) is a memory protection
technology. Your computer uses DEP to mark all memory locations used by applications as
nonexecutable unless the location explicitly contains executable code.
If an application attempts to execute code from a memory page marked as
nonexecutable, the processor can raise an exception and prevent it from
executing. This behavior is designed to thwart a malicious program, such
as a virus, from inserting itself into areas of memory. By allowing only
specific areas of memory to run executable code, DEP protects your computer from many types of
self-replicating viruses.
You can implement DEP via hardware or software. Hardware-based DEP
is more robust because you can extend it to any program or service
running on the computer. Software-based DEP is less robust because it
typically works best when protecting Windows programs and
services.
Windows 32-bit versions support DEP as implemented
originally by Advanced Micro Devices Inc. (AMD) processors that provide
the no-execute page-protection (NX) processor feature. Such
processors support the related instructions and must be running in
Physical Address Extension (PAE) mode. Windows 64-bit
versions also support the NX processor feature but do not need to be
running in PAE mode. And 64-bit computers natively support very large
memory configurations.
You can determine whether your computer hardware supports DEP by
completing the following steps:
In the Control Panel, click the System and Security category
heading link.
Click System. In the left pane under See Also, click
Performance Information and Tools.
Under Tasks, click “Adjust visual effects.” This opens the
Performance Options dialog box.
Click the Data Execution Prevention tab. As Figure 4 shows, the lower
portion of this tab lists the DEP support available.
Once you’ve accessed the Data Execution Prevention tab, you can
configure the way DEP works using these options:
- Turn on DEP for essential Windows programs and services
only
Enables DEP only for the operating system services,
programs, and components. This is the default and recommended
option for computers that support execution protection and are
configured appropriately.
- Turn on DEP for all programs except those I select
Enables DEP for the operating system, as well as all
programs and services you are running.
Because some programs won’t work with or will become unstable with
software-based DEP, you may find that you have to add exceptions when
you enable DEP for all programs. Click Add to specify programs that
should run without execution protection. In this way, execution
protection will work for all programs except those you have
listed.