Sign in with
Sign up | Sign in
Your question

What's a swap disk?

Last response: in Storage
Share
April 19, 2007 9:05:22 PM

What's a swap disk? aka scratch disk, aka page file? I have a drive dedicated for that purpose and I think I have it set up correctly. I set it up without much knowledge so a little explanation (and settings too) would be beneficial.

Windows Vista Premium 32bit
Intel Core 2 Duo E6600 @ 2.70GHz
BFG GeForce 8800 GTX OC
Corsair XMS2 TWIN2X2048-6400 2X1GB DDR2-800
Western Digital 150GB Raptor x2 RAID 0 - OS
Western Digital 150GB Raptor - Data
Seagate Cheetah 18GB 15k - Swap
IBM Ultrastar 40GB 15k - Backup
Sound Blaster X-Fi XtremeGamer Fatal1ty Pro Series
Dell E207WFP & Samsung SyncMaster 213T
Asus Striker Extreme mainboard
PC Power & Cooling Turbo-Cool 1KW-SR
Zalman CNPS9700 NT CPU cooler
Silverstone Temjim TJ07 chassis
Pioneer DVR-212D DVD/CD Writer
APC Back-UPS XS 1000
Coolit Beverage Chiller (pride of the system)
Various trick lighting and LEDs

More about : swap disk

April 19, 2007 9:34:03 PM

A swap disk/file or page file is space used on a Hard Disk as RAM. It is slow and inefficient, but usually the amount of RAM we have in the system just isn't enough in the case when there are too many programs are open and running. With enough RAM you can disable this all together. In my work PC I run 2GB of RAM on WinXP and have the Page File completely disable and haven't ran into any issues. 1GB on my home PC though was not enough and I had to re-enable it in order to run my photo editing software and games.

Having it on a separate dedicated disk will give it a speed enhancement so bravo on that.

In essence the whole reason for having it is because Windows is a 32 bit operating system and does address all 4GB of RAM even though it's not in the system. The page file isn't that large either, but helps the system overall.
April 19, 2007 9:39:55 PM

That's a well-written, informative post. Thanks!
Related resources
April 20, 2007 4:51:10 PM

would it help any to give the page file its own partition on an OS only drive?
April 20, 2007 6:22:31 PM

Quote:
would it help any to give the page file its own partition on an OS only drive?


It won't help speed any, but the one thing it can do is prevent the page file from becoming fragmented. A fragmented pagefile will not perform as well as one that isn't.

Of course, you can usually accomplish the same thing by turning off Windows dynamic resizing of the pagefile and instead specifying a static size. Once the pagefile is set at that size, Windows won't resize it anymore and it cannot get fragmented.

In the end, however, if you're trying to optimize your pagefile to improve performance, you're just shifting chairs around on the deck of the Titanic. :o  Your real problem in this case is that you don't have enough RAM.
April 21, 2007 4:20:59 AM

How about if the OP just disabled the pagefile? In my own experience, I have never seen the memory get maxed out and I have 2 gig. But then again, I still had the pagefile enabled.
So my question is, could the OP get away with disabling the pagefile and it not affect performance?
April 21, 2007 12:41:13 PM

If you have enough RAM, yes, you can disable the pagefile, but I don't recommend it. If the committed memory size begins to get near your RAM size and there is no pagefile available, Windows can start doing very strange things, and in all likelihood, crash.

I always like to have the pagefile enabled even if the machine has a lot of RAM.
April 21, 2007 6:42:40 PM

Quote:

In essence the whole reason for having it is because Windows is a 32 bit operating system and does address all 4GB of RAM even though it's not in the system. The page file isn't that large either, but helps the system overall.


The number of addressable bit has little to do with having a pagefile. You would also need it in a 64 bit environment. You can also have more than 4GB paged to disk in 32 bit Windows
April 21, 2007 8:34:03 PM

I agree that disabling the swap file in Windows is a bad idea. If your memory gets maxed out you can guarantee it will crash or behave badly. Your best bet is to change the size to match the registry size (i.e. 8, 16, 32, 64 Meg). (Windows will actually complain if you set the max size lower than the registry size). For best performance put the swap file on the highest speed/lowest usage drive. Beware that the C: drive will want to have at least 2 meg of swap space on it (another stupid Windows wish).

Bill
April 22, 2007 1:23:35 AM

Quote:
I agree that disabling the swap file in Windows is a bad idea. If your memory gets maxed out you can guarantee it will crash or behave badly. Your best bet is to change the size to match the registry size (i.e. 8, 16, 32, 64 Meg). (Windows will actually complain if you set the max size lower than the registry size). For best performance put the swap file on the highest speed/lowest usage drive. Beware that the C: drive will want to have at least 2 meg of swap space on it (another stupid Windows wish).

Bill


"For best performance put the swap file on the highest speed/lowest usage drive..." Dedicated 2 Raptors in a RAID 0 for the swap file??? :D 
April 22, 2007 4:09:24 AM

OOPS. Should have been more specific.

I meant on your existing drive mix, use the fastest/least used drive. Don't buy a drive just for swap. If you're using swapping at all you should invest in more memory ... if possible.

Taken in the context of setting up a RAID 0 array just for swap, my comment is quite funny. Definate DOH!
April 23, 2007 4:40:01 AM

A swap or page file is a file used by multi-tasking OSs to temporarily store data in RAM that is not being used when another application needs the RAM, and there is not enough physical RAM availble to hold the new and perevious job. The "overflow" is written to a file on the hard drive.

Windows uses a dynamicly sized file by default, and the default location is in the root directory of the first boot drive. The Windows swap file will use as much free space as is available on the hard drive for its swap file. Linux also uses a swap file, but it has the wit to create a seperate partition for the swap file. Automatically and sized to match the RAM in your system.

Windows uses a complicated algorithm to determine which applications to swap out to the hard disk. Generally speaking, the app that has been idle for the longest time is the first one swapped. But not always.

Disabling the Windows swap file is a very bad idea. Windows starts to act up pretty fast if you do that.

What you should do is create a fixed size swap file that then becomes permanent. You do this by getting into the properties and / or disk management dialogues and specifying that the minimum and maximum size of the swap file should be the same. You really want to do this because it will effectively prevent the swap file from fragmenting your hard disk. A seperate drive is a waste for the swap file. What you should do is create a seperate partition for the file on the same drive where Windows is installed and tell Windows to put it there. The partition should be a little larger than the proposed size of the swap file - a little slack space here is a good idea - something like 10% of the size of the file.

As for the size of the file, the general rule is to make the file 2 to 3 times as big as the total amount of RAM in your system, unless you have as much RAM installed as the OS can use. All Windows versions have an upper limit of RAM they can actually use, and some will not work if there is more RAM installed in the system than they were designed to handle. If the amount of RAM in your system is maxed for the version of the OS you are using, the swap file should be no larger than the total amount installed, and a better choice is to make the swap file around half the amount in your system.

Windows 98 could only handle 512 MB of RAM. So if I had less than 512 MB, I would create a permanent swap file 3 times larger than the RAM in the system, but the closer I got to 512 the smaller the file. Windows 2000 could deal with 2GB of RAM, so the swap file would range in size between say 1.5 GB - 512 MB RAM to 3 GB with 1 GB RAM to 1 GB if I have 2 GB RAM. XP can allegedly run with 3 GB RAM, but it doesn't make effective use of anything more than 2 GB. Same principles as for W2K apply

Vista really needs 3 GB RAM to run properly, and it has much more aggressive memory management than XP. It also makes much heavier use of a swap file under some conditions. A seperate partition for a swap file under Vista is a very good idea. I wouldn't recomend making the swap file under Vista any smaller than 2 GB.
April 25, 2007 8:56:26 PM

Wizard said to put the swap file on the same hard drive (different partition) as the windows O/S. I've been told to put it on a separate hard drive from the O/S. What's the benefit of putting the swap file on the same hard drive?
April 27, 2007 5:30:21 AM

Quote:
For best performance put the swap file on the highest speed/lowest usage drive.


For the sake of argument, and if money was no object, and if I had a temporary bout of mental illness, would a dedicated Raptor/RAID 0 array be a dream set-up for a swap file?

Vista 32bit | Core 2 Duo E6600 | BFG GeForce 8800 GTX | Patriot EP 2X1GB PC2-8500 DDR2-1066 CL5-5-5-9 | 3ware 9650SE-4LPML RAID Controller with BBU | 150GB Raptor x2 RAID 0 - OS | 150GB Raptor x2 RAID 0 - Data | 150GB Raptor - Swap/Backup | SB X-Fi XtremeGamer Fatal1ty Pro Series | Dell E207WFP & Samsung SyncMaster 213T | Asus Striker Extreme | PC Power & Cooling Turbo-Cool 1KW-SR | Silverstone Temjim TJ07 | Zalman CNPS9700 NT | 3DMark06: 9705
April 28, 2007 12:21:59 AM

Quote:
Wizard said to put the swap file on the same hard drive (different partition) as the windows O/S. I've been told to put it on a separate hard drive from the O/S. What's the benefit of putting the swap file on the same hard drive?


The benefit is efficiency and reduced overhead. The most active thing in your system is generally the OS, there is always something going on in the background. This is why early versions of MS default defrag progerammes almost always took forever and usually didn't finish. They would stop and resatart whenever the OS accessed the drive. It was quite frustrating to watch this in action. NT didn't include a defrag utility, and the one that comes with W2K, XP and probably Vista is a lobotomized version of a licenced third-party programme.

Since the OS is regularly accessing the drive it is on, it makes sense to put the swap file on the same physical drive as the OS is on. The reason for a seprate partition / drive for the swap file is two-fold. First, it isolates the swap file from the OS and any other apps and files on the drive, reducing the fragmentation of the other drives. Second, it allows independent operation of the swap file, improving performance somewhat. Pputting the swap file on a seperate hard drive is not a very good idea. It makes it necessary for the OS to track and activate two hard drives. This slows down the operation of the swap file and introduces extra overhead. This is less of a problem in current systems, but if one is trying to wring out every last bit of performance, this is a consideration. Besides which, why waste all that space on a second hard drive for a swap file?
April 28, 2007 12:28:50 AM

Quote:
For best performance put the swap file on the highest speed/lowest usage drive.


For the sake of argument, and if money was no object, and if I had a temporary bout of mental illness, would a dedicated Raptor/RAID 0 array be a dream set-up for a swap file?

Vista 32bit | Core 2 Duo E6600 | BFG GeForce 8800 GTX | Patriot EP 2X1GB PC2-8500 DDR2-1066 CL5-5-5-9 | 3ware 9650SE-4LPML RAID Controller with BBU | 150GB Raptor x2 RAID 0 - OS | 150GB Raptor x2 RAID 0 - Data | 150GB Raptor - Swap/Backup | SB X-Fi XtremeGamer Fatal1ty Pro Series | Dell E207WFP & Samsung SyncMaster 213T | Asus Striker Extreme | PC Power & Cooling Turbo-Cool 1KW-SR | Silverstone Temjim TJ07 | Zalman CNPS9700 NT | 3DMark06: 9705

Well, yeah you could do that. And if you had the cash to afforfd it, then there would be nothing to stop you. But you would be making it crystal clear that you prefer to operate in moron-mode if you did that.

You have been asking a bunch of very basic questions - no problem with that. But I have noted that you are also attempting to answer questions in other threads. Given your apparant lack of basic knowledge, and the nature of the specific question quoted above, I really think you shoud refrain from trying to answer questions until you are more knowledgeable.
April 28, 2007 12:45:41 AM

Quote:
Pputting the swap file on a seperate hard drive is not a very good idea. It makes it necessary for the OS to track and activate two hard drives. This slows down the operation of the swap file and introduces extra overhead.


I don't think the extra overhead it takes to manage two drives instead of one, can even be measured against the performance kill it would be to disturb the drive while reading the pagefile or other files. Harddrive access time is measured in milliseconds
April 28, 2007 1:02:40 AM

This almost sounds like this needs to be put to the test by THG
April 28, 2007 1:43:48 AM

Quote:
If you have enough RAM, yes, you can disable the pagefile, but I don't recommend it. If the committed memory size begins to get near your RAM size and there is no pagefile available, Windows can start doing very strange things, and in all likelihood, crash.

I always like to have the pagefile enabled even if the machine has a lot of RAM.
How do you make windows behave and not use the page file until main memory (i.e. RAM) has been used up?
April 28, 2007 5:19:53 AM

Quote:
Pputting the swap file on a seperate hard drive is not a very good idea. It makes it necessary for the OS to track and activate two hard drives. This slows down the operation of the swap file and introduces extra overhead.


I don't think the extra overhead it takes to manage two drives instead of one, can even be measured against the performance kill it would be to disturb the drive while reading the pagefile or other files. Harddrive access time is measured in milliseconds

It depends on what you are doing. You are of course correct about current systems, and I did make the point clear in the sentence that follows the one you quoted. Selective quoteing, like selectiove amnesia, is not a good thing. HArd drive access and seek times are still much slower tham RAM. As for mutiple hard drives and ther like, most people use the seconfd drive fore data files and the like or as a RAID set up.

Putting a swap file, especially one that is run by Windows in dynamic mode - the default - is not a good idea. The swap file in dynamic mode will vary in size up to the full amount of available space on the disc. More, the swap fuile will put itself all over the disc, and fragment the drive. Then there is the performance hit as the frqagments require multiple seeks. This is colloquially known as disc thrashing.
April 28, 2007 9:43:14 AM

Thanks, guys. I partitioned my OS drive and set the page file to 3GB :D 
April 28, 2007 11:10:28 AM

that's an idea. I'd just like to add a few things:
- if you have a truckload of RAM, you can set up a very small static swap file (20 Mb). It shouldn't be actually used, but on the other hand Windows XP's memory manager won't throw a fit because it can't find a page file.
- if you need a swap file, set it to be 150% of your installed RAM (1 Gb RAM= 1.5 Gb swap). On the other hand, past 2 Gb of RAM, said page file becomes too big to be efficient - a better way to get RAM back is to stop unused services and unload unused software (do you need Acrobat loaded all the time? That RealPlayer icon? That Nvidia wizard? Service-wise, do you need desktop themes? fast user switching? Error reporting? The spooler is useless if you don't have a printer, do you really need system restore? etc.)
My last XP system has a 90 Mb memory footprint, antivirus and firewall included; with 2 Gb of RAM, a static swap file of 1 Gb just screams - I play FEAR on it with no trouble.
Ways to improve swap file speed is
1- to put it as close to the outer edge of the hard drive as possible (fastest disk I/O),
2-to put it on a simple file system with very small clusters (FAT32 with 2 Kb clusters does the trick, NTFS not quite as good but...)

The Linux way of using a swap partition has the added bonus that the memory manager has less virtual memory space <=> disk address translations to make.
With a swap file, you need:
- virtual memory address (actual data)
- file offset (where on the swap file)
- file location (where is the swap file on disk - fragmentation hits here)
- drive location (where is the partition on the disk - and LBA translation too, since Windows can't deal with current large drives in direct physical access)
With a swap partition, you need:
- virtual memory address (actual data)
- physical drive location offset (how far from the drive's track 0 is the swap - Linux doesn't require LBA).
Note that on a Linux system, you can 'unplug' the virtual memory and re-enable it on a live system without reboot (the kernel doesn't need virtual memory to run correctly).
Linux can make use of swap files too (on FAT32 and now NTFS volumes), but it is not recommended because it's slower (see reasons above).
April 29, 2007 12:56:39 AM

Quote:

1- to put it as close to the outer edge of the hard drive as possible (fastest disk I/O)


How do I choose where on the hard drive it goes :?:
April 29, 2007 7:38:36 AM

some defragmenters allow you to free some space at the 'top' of the disk. Unfortunately, most cost some money, except one: jkdefrag. This one is free, however you need to use the command line to configure it. See its home page for ways on how to put the swap file at the top of the disk (most hard disks start their addressing at the outer edge - faster - and go inside; CDs/DVDs start on the inner edge and go outside - accomodates various capacities and diameters)
!