📄 virtual memory optimization guide rev. 4.0 - final.txt
字号:
Check out this transfer rate graph of a hard disk :-
It shows pretty clearly the transfer rate of a hard disk is highest on the outer tracks and lowest on the inner tracks. In this case, the transfer rate of the inner tracks is only about half the transfer rate of the outer tracks.
The areal density of a hard disk's platters and its spin rate are constant. But the linear velocity at each point of the platter isn't constant. Therefore, the performance of the paging file depends on where it is located on the hard disk.
The time taken for the hard disk head to read from point A to point B is exactly the same as the time taken for the head to read from C to D. But because the areal density of the platter is constant, a lot more data can be read from the outer tracks than from the inner tracks, in the same amount of time.
Now that the outer tracks have been proven to be the fastest area on a hard disk, we can use that to our advantage. By moving the paging file to the outer tracks, we give the paging file a major boost in performance.
As you can see from the example above, the transfer rate at the outer tracks are about 59MB/s while the central and inner tracks have transfer rates of about 49MB/s and 30MB/s respectively. Moving the paging file from the inner tracks to the outer tracks will almost double its performance! Even moving the paging file from the central tracks to the outer tracks will give the paging file a transfer rate boost of 20%.
But please note that this method must be used in conjunction with a permanent paging file. This is because the paging file cannot be moved to the outer tracks of the hard disk unless it is a permanent paging file.
How Do We Move The Paging File To The Outer Tracks?
Before you can move the paging file to the outer tracks, you must first make the paging file permanent. Follow the steps outlined in the previous pages. Once you have a permanent paging file, you can use your favourite hard disk defragmentation utility to move the paging file to the outer tracks.
Unfortunately, Windows XP's Defrag utility does not have the ability to move paging file to the outer tracks. You will have to use a third-party defragmentation utility to move the paging file to the outer tracks. I will use Diskeeper as an example.
Windows NT, 2000 and XP does not allow the paging file to be moved while it is in used. Therefore, you must set Diskeeper to move the paging file during the next reboot.
Run Diskeeper and click on Change your settings to expand its menu. You will see the screen below.
Look for and click on Set a boot-time defragmentation. That will display this screen.
Now, select the partition where the paging file resides and tick the checkbox of Defragment the paging file option. The option will be grayed out if there is no paging file in that partition.
Then click OK and reboot the computer. Diskeeper will load up during the boot process and defragment the paging file. It will also move the paging file to the outer tracks.
Once Diskeeper has completed its operation, Windows XP will boot up and start using the newly optimized paging file that is not only contiguous but also located in the outer tracks of the hard disk! Your paging file will now show a marked boost in performance.
Please note that you cannot actually force Diskeeper to move the paging file right up to the outermost tracks. Diskeeper has an internal algorithm that determines which files are best placed in the outermost tracks for optimal performance.
In addition, Diskeeper requires a certain amount of free space to defragment and move the paging file. If you do not have the necessary amount of free space in that partition, then Diskeeper may not defragment the paging file or move it to the outer tracks.
Creating A Huge Paging File
Because games and applications often list a minimum paging file size, many people equate the size of the paging file with performance, just like they would with anatomy. But at least in the first case, that's not true.
What does a bigger paging file get you? Well, it gives you the ability to run more memory-intensive programs concurrently. But does a larger paging file make virtual memory faster or better? Unfortunately, the answer is no.
Why Not?
First of all, creating a large amount of virtual memory doesn't mean the operating system will use it all. Although Windows will pre-emptively page out parts of idle applications, there are limits to how much it can page out for each application. Therefore, creating an excessively large paging file will just waste hard disk space.
Second, if you ever move the paging file to the outer tracks of the hard disk, an excessively large paging file will take up outer track space that could have been used to store system or application files. Look at these two pictures :-
Hard disk with a 2GB paging file (brown)
Hard disk with a 600MB paging file (brown)
The first one has a huge 2GB paging file while the second has a smaller 600MB paging file. For many systems, 600MB of virtual memory is more than enough to multitask 7 or 8 applications at the same time or run the most memory-intensive 3D games out there. So, anything more is just taking space.
The extra space taken up by an excessively large paging file on the outer tracks could have been used to store system or application files for faster access. The amount of space regained from using a smaller page file can be seen as a red block in the second picture. You can bet on a faster loading time for Windows and other applications if you limit the size of your paging file.
Therefore, the trick here is to gauge the maximum size of the paging file that you will ever need. This way, you will not create an excessively large paging file that wastes hard disk space and takes up the precious space on the outer tracks away from the system and application files.
How Large Should The Paging File Be?
That's a question that has bugged many users. Since the good old days of DOS and Windows 3.1, many users have staunchly adhered to an old rule of the thumb that the swapfile should be 2.5 x the amount of RAM.
In fact, whenever I visit other forums, I still notice many people quoting this old "rule". The question is - is this rule still applicable for today's systems and operating systems? Unfortunately, it's a big NO!
Why Not 2.5 x RAM?
Back in the Windows 3.1 days, computers only came with 4MB or 8MB of RAM. 16MB of RAM was considered a luxury in those days. I remember running Windows 3.1 on an Intel i386SX-16 machine with just 4MB of RAM!
Because RAM in those days was horrendously expensive and only a limited amount of it was available in most systems, a relatively large swapfile was needed. A swapfile size of 2.5 times the system RAM wasn't a lot, considering the fact that most systems came with only 4MB or 8MB of RAM. That would only amount to a swapfile size of 10MB to 20MB, which enabled most systems to run Windows 3.1 applications comfortably.
But today, most computers come with at least 512MB of RAM and many have 1GB of RAM! If the 2.5X rule was applied, that would result in "optimal" paging file sizes of 1.28GB to 2.5GB! That doesn't make sense at all.
The purpose of buying more memory is to prevent the system from using the slower virtual memory. The more memory you buy, the less you need to use virtual memory. It doesn't make sense to increase the paging file size every time you increase the amount of RAM in your system!
Imagine if you have follow the rule when you upgrade to 2GB of RAM in the future... You would have to create a 5GB paging file! That's ridiculous.
The amount of hard disk space you dedicate to a paging file should depend on the amount of RAM you need to use, NOT the amount of RAM you have. The 2.5 x system RAM rule was flawed from the beginning and it is certainly not applicable today.
Do not use the 2.5 x system RAM rule to determine the size of your paging file. Instead, you should first gauge how much virtual memory is actually needed by the system during the heaviest memory load. Then use your finding to set the most appropriate paging file size for your system.
But You Require A Huge Paging File For A Memory Dump!
There are people who actually believe in increasing the size of the paging file following an increase in system memory. That certainly goes against what we have been recommending, doesn't it? The reason is simple.
Whenever Windows crashes, it first writes the memory contents to the paging file. After the computer is restarted, Windows will create a memory dump file using the memory contents stored in the paging file. This memory dump file is used to analyze the cause of the crash.
However, for a complete memory dump to created, the paging file size should be large enough to store all the contents of the system memory. That's why the paging file size has to meet this equation :-
Paging file size = Physical memory in the system + 1MB
So, if you have 1024MB of memory, the paging file size should be 1025MB in size for a complete memory dump to be created successfully.
However, this does not mean you should increase the size of your paging file according to the amount of system memory. Why not? Let's find out.
Why Not?
First of all, there is no need to create a complete memory dump. Windows supports three different kinds of memory dumps. Here is a summary of information from Microsoft's Knowledge Base.
Type Of Memory Dump
Description
Size
Small
* Small memory dump files contain the least information, but consume the least disk space, 64 kilobytes (KB).
* Unlike kernel and complete memory dump files; Windows XP stores small memory dump files in the systemroot\Minidump folder, instead of using the systemroot\Memory.dmp file name.
* Windows XP always create a small memory dump file when a Stop error occurs, even when you choose the kernel or complete memory dump file options.
* One of the services that use small memory dump files is the Error Reporting service. The Error Reporting service reads the contents of a small memory dump file to help diagnose problems that cause Stop errors.
64KB
Kernel
* This is an intermediate size dump file that records only kernel-level memory and can occupy several megabytes (MB) of disk space.
* When a Stop error occurs, Windows XP Professional saves a kernel memory dump file to a file named systemroot\Memory.dmp and create a small memory dump file in the systemroot\Minidump folder.
* You cannot exactly predict the size of a kernel memory dump file because this depends on the amount of kernel-mode memory allocated by the operating system and drivers present on the machine when the Stop error occurred.
About 1/3 of system memory
Complete
* A complete memory dump file contains the entire contents of physical memory when the Stop error occurred.
* The file size is equal to the amount of physical memory installed plus 1 MB.
* When a Stop error occurs, the operating system saves a complete memory dump file to a file named systemroot\Memory.dmp and creates a small memory dump file in the systemroot\Minidump folder.
System memory + 1MB
Although you may think that it is always good to create a complete dump file. However, that is not true. Even Microsoft recommends creating a kernel memory dump, instead of a complete memory dump. Why? I'll quote them :-
For most purposes, a kernel memory dump file is the most useful kind of file for troubleshooting Stop messages. It contains more information than the small memory dump file and is significantly smaller than the complete memory dump file. It omits only those portions of memory that are unlikely to have been involved in the problem.
In addition, a kernel memory dump will require the paging file to be only about 1/3 of the system memory. It will also require the same amount of free hard disk space.
Even if you wish to create a complete memory dump, there is still no need to create a large paging file. Even if you restrict your paging file to, for example, 500MB; Windows XP will automatically expand the paging file to store the memory dump BEFORE it is written out to disk on the next reboot.
Therefore, I consider it to be a real waste of hard disk space if you have 2GB of memory and yet create a 2GB paging file, just so Windows XP can write an enormous memory dump the next time it crashes.
How Much Virtual Memory Do I Need?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -