Although the hard disk is much slower than RAM, it is also much cheaper and users always have a lot more hard disk space than RAM. So, Windows and other OSs are designed to create this pseudo-RAM or in Micro$oft's terms - Virtual Memory, to make up for the shortfall in RAM when running memory-intensive programs. Virtual memory is created using a special file called a swapfile or pagig file. Whenever the operating system has enough memory, it doesn't usually use virtual memory. But if it runs out of memory, the operating system will page out the least recently used data in the memory to the swapfile in the hard disk. This frees up some memory for your applications. The operating system will continuously do this as more and more data is loaded into the RAM. The swapfile and paging file are really quite different. Although both are used to create virtual memory. The main difference is that Swapfiles operate by swapping entire processes from system memory into the swapfile. This immediately frees up memory for other applications to use. In contrast, paging files function by moving "pages" of a program from system memory into the paging file. These pages are 4KB, or more, in size. The entire program does not get swapped into the paging file. While swapping occurs when there is heavy demand on the system memory, paging can occur pre-emptively. This means that the operating system can page out parts of a program when it is minimized or left idle for some time. The memory used by the paged-out portions is not immediately released for use by other applications. Instead, they are kept on standby. If the paged-out application is reactivated, it can instantly access the paged-out parts (which are still stored in system memory). But if another application requests for the memory space, then the system memory held by the paged-out data is released for its use. so, this is really quite different from the way a swapfile works. Swapfiles were used by Microsoft prior to Windows 95. From Windows 95 onwards, all Windows versions use only paging files. The correct term for the file used to create virtual memory in current operating systems is paging file, not swapfile. | |||||||||||||||
Nowadays; when the average home user's computer comes with at least 512MB of RAM, the paging file is still very important. The large amount of RAM found in the average user's computer reduces the risk of memory shortage with single applications, however; the paging file is essential when multi-tasking. As multi-tasking has arrived for good at last on the PC platform (the Amiga OS had it from the very start). We can now run loads of applications at the same time. It is common to have 15 or more applications running together. With 512MB of RAM, it could be possible to load everything into memory. But a paging file is really needed to stop the system from crashing, and store the least used data into the virtual memory. It should be noted that Win98 and XP allocate a sizeable portion of the RAM to the disk cache. This speeds up accesses to hard disk data by caching the most frequently used as well as data that are most likely to be accessed next by the computer. This cuts down on the amount of available RAM. So, without a paging file, you won't be able to open many applications with, say, 256MB of RAM. Unless your computer at least a Gigabyte of RAM, it will almost always use the paging file. As such, its performance affects the performance of the whole computer. Even the fastest hard disk is currently over 70X slower than the slowest dual-channel PC2700 DDR memory common in many computers. (But hopefully you're using the faster PC3200 DDR memory or PC2-4200 DDR2 memory.) Remember: Paging file is only a stopgap solution for the lack of sufficient RAM. As long as you use the paging file, there will always be performance degradation. The ideal solution for insufficient RAM is always more RAM, not more Virtual Memory. Remember, more paging file space will give you the ability to run more memory intensive programs at once. However, it will not speed up your system. But there are a few tricks we can do to optimise the paging file so that the performance degradation when using it is minimized. | |||||||||||||||
| |||||||||||||||
Back in the bad old days of DOS 6.22 and Windows 3.1, a permanent swapfile was the best solution for optimal swapfile performance. Windows 3.1 only creates contiguous, permanent swapfiles. A contiguous swapfile is a swapfile that consists of an uninterrupted block of hard disk space. When a swapfile is contiguous, the read-write heads of the hard disk can read and write data on the swapfile in a continuous fashion. However, this dynamic virtual memory system does have a big disadvantage - it cannot be moved to the outer tracks of the hard disk platters. A contiguous paging file eliminates the need for the hard disk heads to seek all over the platters while accessing the paging file. | |||||||||||||||
See how a contiguous paging file differs from a fragmented paging file? Instead of seeking and reading from a continuous block of hard disk space in the case of a contiguous paging file, the hard disk heads have to seek all over the platters to access the clusters allocated to a fragmented paging file. As a result, a common operating pattern like the following may emerge :- | |||||||||||||||
Of course, the amount of time needed to do the seek operation is different from the time needed to read a block of data off the paging file but the logic remains. Now that we agree that making the paging file contiguous will greatly improve its performance, let's figure out how to make it contiguous. | |||||||||||||||
Fragmented : seek-read-read-seek-read-seek-read-read-read-seek-read-read-seek Contiguous : seek-read-read-read-read-read-read-seek-read-read-read-read-read | |||||||||||||||
"Simple! Just make the paging file permanent!" Hum, creating a permanent paging file is usually the way to create a contiguous paging file. A permanent paging file ensures that the paging file will remain in one single block. However, creating a permanent paging file does not mean the paging file will automatically become contiguous. That may have been true in Windows 3.1 but, Windows XP does not force the creation of a contiguous paging file when you make the paging file permanent! A contiguous paging file allows data to be read with minimal amount of seeks. If the number of seeks can be reduced while accessing the paging file, then more data can be read in less time. This is the premise behind a contiguous paging file. With a permanent paging file, the application will just halt with the error message and you would have to close one or more applications to free up more memory. However, this is only true for older versions of Windows. Newer iterations of Windows like Windows XP do not have a true permanent paging file. Even if you set a permanent paging file, Windows XP will automatically generate more virtual memory when it runs out of memory; by adding a dynamic component to the permanent paging file. In short, when you create a "permanent" paging file in Windows XP, you are actually creating a semi-permanent paging file. The bonus of a semi-permanent paging file, instead of a "permanent" paging file in Windows XP is that there isn`t the warning message that appears whenever Windows XP runs out of memory and has to create more virtual memory by adding a dynamic component to the permanent paging file. | |||||||||||||||
But just how bad could be the deterioration be?
You will notice that the paging file is split into two parts. The permanent part is at the outer tracks of the hard disk in one contiguous block. The lower, fragmented blocks of paging file are the dynamic part of the semi-permanent paging file. As the paging file requirement exceeds what the permanent part can provide, the dynamic part of the semi-permanent paging file will dynamically convert available hard disk space (which is usually on the inner tracks on the hard disk) into virtual memory. | |||||||||||||||
This shows a semi-permanent paging file (brown) Because the paging file's two components are at opposite ends of the hard disk, the hard disk heads will have to seek up and down the platters while servicing the paging file! Needless to say, that greatly degrades the performance of the paging file. The head seeks required to service a dynamic paging file are already bad enough. The amount of head seeks required to service both the permanent part and the fragmented dynamic part will definitely put a big dent on the paging file's performance.
| |||||||||||||||
Performance-wise, both a permanent and a semi-permanent paging file will perform equally, if the virtual memory requirement does not exceed what the permanent component of the semi-permanent paging file can provide. As the dynamic part comes into play, the semi-permanent paging file gradually loses its performance advantage over the dynamic paging file. Eventually, it may even become slower than a dynamic paging file. Creating a permanent or semi-permanent paging file inevitably causes numerous writes and rewrites of information in the same fixed area of the hard disk platters. Compared to other areas of the hard disk, the space allocated to the paging file will be the area where data is most often written, deleted and replaced with newer data. Well, unlike magnetic cassettes or floppy disks, there is actually no contact between the hard disk read-write heads with the platters. The read-write heads actually fly over the platters on a thin cushion of air. In fact, at the high speed that the platters are spinning at, any contact between a read-write head with a platter would have resulted in a head crash, with disastrous consequences. This should not hurt the drive at all. As you are aware, the heads are actually suspended above the platters on an air bearing, so there is no direct contact with the media. As far as the recording and re-recording of the same tracks, also no problems. What we are dealing with here in order to write the data is simply moving the magnetic domain one way or the other, no wear involved. - Bob Seagate Tech Support Remember, the heads truly fly above the media. The wear and tear factor only becomes an issue for bearings (heat) and physical damage to the media if the drive is shocked during operation. Performance is best at the outer tracks of the drive, so any recurring access directed there will benefit you in performance. Writing and rewriting data to a drive is good in that it remagnetises (refreshes) the area every time it is written. Your swap file will not affect the MTBF of your drive. - Don Gardner IBM Hard Disk Technical Support/SIT Lab Well, it appears to be so. The signal carried by the media weakens with time and rewriting it refreshes and strengthens the signal strength of the data carried by the media. | |||||||||||||||
Creating A Permanent Paging File In Windows 9x Luckily, Microsoft gave us a relatively painless way to create a permanent paging file though the proper directions were not included. First, open up System Properties, either through the Control Panel or by right-clicking on the My Computer icon and selecting Properties. Once in System Properties, click on the Performance tab. Right at the bottom, you'll see a Virtual Memory button. By default, it is set to Let Windows manage my virtual memory settings. (Recommended). Ignore the Recommended label and select Let me specify my own virtual memory settings. Now, you will be allowed to choose the partition you wish to place the paging file in. We will touch on this later. Next up is the minimum and maximum values for the paging file. To create a permanent paging file, both values must be the same. You would think that Microsoft could at least post a notice about that. Please note that Windows 95/98 will not automatically add a dynamic component to a permanent paging file. If you run out of memory with a permanent paging file, it will halt the application and generate the "Out of memory" error message. Naturally, you will have to decide on a size for the paging file. We will be discussing this later in the guide but in this example, we will use an arbitrary value of 150MB. Once you set the two values, click on OK and then let Windows 95/98 reboot the system. A permanent paging file will be created on your hard disk. | |||||||||||||||
For the curious, do not click on Disable virtual memory. (Not recommended) because that will force Windows 95/98 to use only physical RAM. In Windows 2000, it takes a little bit more digging to get where you want. First, open up System Properties, either through the Control Panel or by right-clicking on the My Computer icon and selecting Properties. Once in System Properties, click on the Advanced tab. There will be three options. Click on Performance Options... The second section you see is titled Virtual Memory. Under it, there's a Change button. By default, there won't be any values set for both the Initial size (MB) and the Maximum size (MB) options. You can select the partition you wish to place the paging file in by clicking on the list of partitions shown on the screen. Again, the selection of partition will be discussed in detail later in this article. To create a permanent paging file, both values for the Initial size and the Maximum size must be the same. Once in System Properties, click on the Advanced tab. There will be three sections. Click on Settings in the Performance section and the Performance Options screen will pop up. | |||||||||||||||
The second section you see is titled Virtual memory. Under it, there's a Change button. You can select the logical drive you wish to place the paging file in by clicking on the list of logical drives shown on the screen. Again, the selection of logical drives will be discussed in detail later in this article. To create a permanent paging file, both values for the Initial size and the Maximum size must be the same. Please note that Windows XP will dynamically expand the paging file when you run out of memory, even if you create a permanent paging file. When this happens, you will get an error message telling you that Windows XP is trying to expand the paging file to create more virtual memory. In this example, we are using an arbitrary value of 512MB. Once you set the two values, click on OK and then let Windows XP reboot the system. A permanent paging file will be created on your hard disk. You will note that Windows XP does not allow a paging file size of less than 2MB. Creating a semi-permanent paging file is rather similar to creating a permanent paging file. First, open up System Properties, either through the Control Panel or by right-clicking on the My Computer icon and selecting Properties. | |||||||||||||||
Once in System Properties, click on the Advanced tab. There will be three sections.
Click on Settings in the Performance section and the Performance Options screen will pop up. Click on the Advanced tab. The second section you see is titled Virtual memory. Under it, there's a Change button. You can select the partition you wish to place the paging file in by clicking on the list of partitions shown in the window. To create a semi-permanent paging file, you will need to set both the minimum and maximum values. They must not be the same. If they are the same values, then the paging file becomes a permanent paging file. The minimum value determines the size of the permanent component of the semi-permanent paging file. The maximum value determines the maximum size of the paging file (both permanent and dynamic components) and thus limits how much the dynamic component can expand. | |||||||||||||||
Windows XP will create a permanent paging file of 512MB when it starts up. But if the paging file cannot meet the memory demands of the computer, it will dynamically expand the paging file, up to a maximum of 768MB. It is highly recommended that you create a large permanent component that will meet all of your usual memory needs. Use the dynamic component as a backup for emergencies. Once you set the two values, click on OK and then let Windows XP reboot the system. A permanent paging file will be created on your hard disk. Please note that the dynamic component of the paging file will only become active after the system's virtual memory requirements exceed the minimum value. You will note that Windows XP does not allow a paging file size of less than 2MB. First, open up System Properties, either through the Control Panel or by right-clicking on the My Computer icon and selecting Properties. Once in System Properties, click on the Advanced tab. There will be three sections. Click on Settings in the Performance section and the Performance Options screen will pop up. Click on the Advanced tab. The second section you see is titled Virtual memory. Under it, there's a Change button. | |||||||||||||||
You can select the partition you wish to place the paging file in by clicking on the list of partitions shown on the screen. Again, the selection of partition will be discussed in detail later in this article. To create a semi-permanent paging file, you will need to set both the minimum and maximum values. They must not be the same. If they are the same values, then the paging file becomes a permanent paging file. The minimum value determines the size of the permanent component of the semi-permanent paging file. The maximum value determines the maximum size of the paging file (both permanent and dynamic components) and thus limits how much the dynamic component can expand. In the example above, Windows XP will create a permanent paging file of 512MB when it starts up. But if the paging file cannot meet the memory demands of the computer, it will dynamically expand the paging file, up to a maximum of 768MB. It is highly recommended that you create a large permanent component that will meet all of your usual memory needs. Use the dynamic component as a backup for emergencies. Once you set the two values, click on OK and then let Windows XP reboot the system. A permanent paging file will be created on your hard disk. Please note that the dynamic component of the paging file will only become active after the system's virtual memory requirements exceed the minimum value. You will note that Windows XP does not allow a paging file size of less than 2MB. Making The Paging File Contiguous After creating a permanent or semi-permanent paging file, check and make sure it is contiguous. You can ensure it is contiguous by defragmenting the hard disk before you creating the permanent or semi-permanent paging file. However, that does not always work.. | |||||||||||||||
Moving The Paging File To The Outer Tracks Moving the paging file to the outer tracks is a powerful way of increasing paging file performance. In fact, it will give the paging file a bigger boost in performance than just making it contiguous. Why is that? | |||||||||||||||
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. (though third party software does, eg disk keeper) And Windows NT, 2000 and XP does not allow the paging file to be moved while it is in used. A tweak that i have used is not use NTFS for the paging volume. | |||||||||||||||
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. 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 Much Virtual Memory Do I Need? No one can tell you how much hard disk space you need to allocate to a permanent paging file because every system is different and everyone uses his/her system differently. If you create a permanent paging file that is too small, then Windows will continuously create more virtual memory via a dynamic extension to the permanent paging file. This reduces the paging file's performance. Finding Out In Windows 9x Give your system a clean boot and once you are in Windows 95/98, load System Monitor. You can get to it via Start Menu > Programs > Accessories > System Tools. Go to the Edit menu and click on Add Item... In the next screen, select the Memory Manager category and add Swapfile in use. Click OK . Now, you can monitor the size of your paging file. Start up and run all the applications that you usually use at the same time. Load several documents and work files. Play around with them and check the peak value for the paging file. Then play several of the most memory-intensive games you have. 3D games with large textures are good ones to test. At all times, record down the highest value for the paging file size that System Monitor reports. | |||||||||||||||
How Much Virtual Memory Do I Need?
Finding your optimal paging file size in Windows XP is much easier. Just give your system a clean boot. Once you are in Windows XP, run Task Manager . You can get to it by right-clicking on the taskbar and selecting Task Manager. You can also access it through the keyboard shortcut of Ctrl-Alt-Del. After you load Task Manager, click on the Performance tab. The item of interest here is the PF Usage meter. The PF Usage meter shows you the amount of paging file that is being used as virtual memory. Now, you can monitor the size of your paging file. Start up and run all the applications that you usually use at the same time. Load several documents and work files. Play around with them and check the peak value for the paging file. Then play several of the most memory-intensive games you have. 3D games with large textures are good ones to test. At all times, record down the highest value for the paging file size that System Monitor reports. Once you are done, select the highest value that has been recorded for the paging file size and round it up to the nearest 100MB. For example, if the biggest size your paging file ever went during the tests was 619MB, then 700MB is the ideal size for your paging file. But always make sure you add at least 40-50MB as a cushion against future memory-guzzling applications or games. For example, if the largest size your paging file expanded to during your tests was 684MB, then 750MB would be an ideal size for your paging file.
| |||||||||||||||
Improve Swap File Performance (Windows 98) If you've got an old win98 computer with 32MB of RAM or more, try setting the cache size at a fixed number. I recommend 4MB for systems with less than 48MB of RAM, and one QUATER total RAM for those with 48MB or more. Here's how to set it up: Run SysEdit. (Select Run in your Start menu, type SysEdit in the text box, and press Enter.) Click in the system.ini window. Scroll down to the [vcache] section. If you don't see one, type in [vcache] as a new heading. If you have 48MB of RAM or less, enter these two lines: If you have more than 48MB of RAM, enter these two lines: Close SysEdit, saving changes on the way out, and restart Windozes.
Moving The Paging File To A Different Partition Another popular technique proposed by many tweakers suggests moving a temporary paging file from the default first partition to a separate, dedicated partition. There are two main reasons for this tweak: to reduce fragmentation of the first partition to ensure that the paging file will remain contiguous even though it is a temporary paging file This idea looks good because it enables users of temporary paging files to keep their primary partition neat and the paging file contiguous for a speed boost. | |||||||||||||||
Cylinders And Partitions If we take a look at a hard disk cylinder, we see that a cylinder consists of the same tracks on all the platters in the hard disk.
The first cylinder, nominally called cylinder 0, (coloured in bright green), is the outer most cylinder and consists of the first track of all the platters in the hard disk. Such groups of tracks have a cylindrical look, hence the name. Cylinder n (in red) is the last cylinder of the hard disk, where n can be any integer. Partitions are constructed using full cylinders. The first one starts at cylinder 0 and go out to where you specify. The next one starts on the following cylinder, and so on. If you try to create a partition with an end that falls in the middle of the cylinder, FDISK or similar utilities will round it up so that the partition occupies the entire cylinder, instead of a partial cylinder.
Needless to say, the first partition will always start with the first track of every platter. In other words, the first partition will always be the fastest partition in the hard disk, followed by the second partition and so on. Therefore, if you create a second partition and dump the paging file there, you will actually be moving it to a slower part of your hard disk! As you can see, while the temporary paging file will be remain contiguous using this technique, the transfer of the paging file from the outer tracks to the inner tracks of the hard disk will inevitably reduce its performance.
| |||||||||||||||
Need More Reasons? Creating a dedicated partition for the dynamic paging file also means tying up hard disk space and inviting inflexibility. More Partitions = Data Safety? The reason for using multiple partitions for safety is that in the event of a hard disk crash, corruption to the boot sector or FAT (File Allocation Tables), only the primary partition will be lost, leaving precious data safe in the other partitions. "It's not a substitute for a good backup, but it may save you from having to restore all of your data from a backup. However, if your first partition is taken out, more than likely the whole drive will be lost. The first partition is also the location of the Master Boot Record and the partition table." - Russ Johnson, a Product Support Engineer from Symantec Corporation Storing your data on a different partition is actually a good practice. It can save your data if the first partition gets corrupted due to a soft error. For example, even if the FAT of one of the partitions gets corrupted, data on the other partitions will still be safe. How Do I Move The Paging File In Windows XP? First, open up System Properties, either through the Control Panel or by right-clicking on the My Computer icon and selecting Properties. Once in System Properties, click on the Advanced tab. There will be three sections. Click on Settings in the Performance section and the Performance Options screen will pop up. Click on the Advanced tab. The second section you see is titled Virtual memory. Under it, there's a Change button. This is where you manage Windows XP's paging file settings. You can select the logical drive you wish to place the paging file in by clicking on the list of logical drives shown on the screen. Just scroll through the selection of logical drives available. Click on the logical drive that you want to place the paging file. Then set the initial and maximum paging file sizes and click Set. To remove the paging file from the default location in the first logical drive, select drive C: and select No paging file. Then click Set. After you are done, just click OK and allow Windows XP to reboot your computer. After rebooting, your paging file will be established in the logical drive you selected. Registry hacks for Windows XP. DisablePagingExecutive default setting was "set" when RAM was precious and scarce. Portions of system code and device drivers can be paged to disk when the system needs more page frames in RAM. The system slows when it next needs that code or drivers since it must load them from the page file. The system stops while the required code is swapped in or out of RAM dependent on very long hard drive access times. If you have more than sufficient RAM, disabling paging will speed the system overall and reduce the amount of `swapping` on your hard-drive. Don`t turn on this option with less than 512M, at least for W2K and XP Pro. A CPU intensive setting. Hive: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager Imprtant: note that each logical drive represents a partition, not a physical drive. So, if you want to move your paging file to a separate hard disk, select a logical drive that resides on that hard disk. Preferably, it should be the first partition in the other hard disk (which should be on its own IDE channel). | |||||||||||||||
Giga-byte's i-RAM is a PC add-in card with four DDR DRAM (double data rate dynamic RAM memory) slots that's designed to be used as a PC drive. Because the i-RAM uses DRAM rather than a hard disk to store information, data can be retrieved from the drive up to 60 times faster than is possible with a hard drive. i-RAM uses solid state storage that is powered through a PCI slot and battery backup so that the volatile memory is not wiped. With no moving parts, speed and reliability is improved tremendously, and at the same time, random accesses are no longer limited by slow and difficult to position read/write heads of conventional magnetic hard drives. By utilizing conventional DDR memory modules, Gigabyte's i-RAM is a lot cheaper to implement than more conventional solid state devices. HDBENCH(Ver3.40 beta6)
(ie. better off with more memory in the system than an i- RAM). But if you got both; you may as well make it your pagefile device… On memory hogs like web pages with lots of Flash, Photoshop, etc. the system sometimes still resorts to pagefiles; as a consequence the system will run faster, and accessed much quicker off the i-RAM than a mechanical hard disk. |
| |
| |
| |
| |