Defrag swap space in XP - Page 1
Forum section: electronics / general

author: robrenz
author_rank: Super Contributor
timestamp: March 30, 2012, 03:19:18 pm
content: When I defrag my hard drive there is the protected swap space that does not get defragged. After 5 years the swap space is extremely fragmented and I can tell performance of my dell workstation is hampered. Is there a way to defrag the swap space other than a total disk format and reload all software and files again?

author: SoftwareSamurai
author_rank: Regular Contributor
timestamp: March 30, 2012, 03:38:08 pm
content: Perhapssomething like this?

author: Lightages
author_rank: Unknown
timestamp: March 30, 2012, 03:45:20 pm
content: Although this is an electronics forum and not a computer support forum, I guess I will step in and helpYou need to right click on My Computer then click on Properties/Advanced Tab/Performance Settings button/ Advanced Tab/Virtual Memory Change button. Then click on No paging file. Reboot, delete the pagefile, run your favorite defrag program. Once completed, do not do anything else except make a "Custom size:" paging file. Set the minimum to at least 2048 and a maximum of 4095. Once this is done, windows will build a new paging file that is contiguous and it will not fragment again.

author: robrenz
author_rank: Super Contributor
timestamp: March 30, 2012, 03:53:56 pm
content: Thanks for making an exceptionIn your instructons can I use the standard windows defrag that I have been using or do I need a second source defrag to work? Thanks again for your help.

author: grenert
author_rank: Frequent Contributor
timestamp: March 30, 2012, 04:04:25 pm
content: I use Raxco Perfectdisk, and it will defrag your swap files as well as other system files. It is pretty cheap ($25) and you can download a trial version to see if it improves the performance of your computer.

author: sonicj
author_rank: Frequent Contributor
timestamp: March 30, 2012, 04:07:01 pm
content: i likemydefrag.

author: Deepak
author_rank: Regular Contributor
timestamp: March 30, 2012, 04:24:35 pm
content: Quote from: robrenz on March 30, 2012, 03:53:56 pmStandard tools are fine. Here's a detailed guide if you need it:http://windowsdevcenter.com/pub/a/windows/2004/11/23/defrag_pagefile.html

author: Monkeh
author_rank: Super Contributor
timestamp: March 30, 2012, 04:30:53 pm
content: Disable pagefile, reboot, delete pagefile, defrag, enable pagefile at a fixed size. It will never become fragmented again.

author: mariush
author_rank: Super Contributor
timestamp: March 30, 2012, 04:46:30 pm
content: I'm using O&O Defrag.Go and set the pagefile to a fixed size, reboot and windows will create a new pagefile. Then defrag and o&o defrag will move the whole continuous page file at the start of the drive.As it's fixed size, windows will never move it from that spot ever.2-4 GB is plenty of page file, no need to set a bigger one.

author: Sionyn
author_rank: Frequent Contributor
timestamp: March 30, 2012, 08:07:49 pm
content: check out vopt

author: BravoV
author_rank: Super Contributor
timestamp: March 30, 2012, 08:55:37 pm
content: How many HD do you have there ? Or if you HD has more than 1 partitions, then the fastest, easiest and cleanest way to defrag the page file (swap file) is to disable the swap file by setting it to 0 (zero) on the current boot drive/partition. Then again set the swap fle at other drive/partition just for temporary.This will effectively clean your from drive from swap file without any hassle, and from here launch your favorite defragger and if it has an option to defrag + to make contiguous free space, choose this option and use it, this will defrag those ordinary files easily without that big chunks of swap file. Once the defragger finished the job, move back the swap file back to the previous drive/partition and don't forget to disable (set to zero) at that temporary disk/partition.The newly create swap file on the fresh defragged drive will occupy the freed contiguous free space without any defragmentation, and although it sounds complicated, this will beat any defragger out there in term of speed & quality of the swap file defragmentation.Also to avoid further defragmentation in the future, set the minimum and maximum size to equal, this will set the page file permanently at the place where it was created from the 1st time, and it won't grow anymore causing defragmentation in the future. If you don't use heavy memory programs and have say 4 or 8 GB of memory, "usually" a fixed page file size of 4096 MB or 8192 MB is more than enough.

author: Rerouter
author_rank: Super Contributor
timestamp: March 30, 2012, 08:56:55 pm
content: lightags, a better method is to make a paging files max and min the same, that way windows doesnt go resizing it and it will not fragment, it also helps a little on mechanical hard drives as windows wont be screwing around adding and removing chunks of itself,

author: Psi
author_rank: Super Contributor
timestamp: March 30, 2012, 09:32:52 pm
content: You can run without a pagefile entirely, but the PC will BSOD when it runs out of ram.Guy i know with 12GB of ram has no pagefile and has never had any issue since he did it 2 years ago.

author: G7PSK
author_rank: Super Contributor
timestamp: March 30, 2012, 09:41:05 pm
content: Auslogics defrag is very good they also do a page defrag version.

author: benemorius
author_rank: Regular Contributor
timestamp: March 30, 2012, 10:02:22 pm
content: This is offtopic of course, but you might want to consider that the fact that your swap space is being used at all is not ideal. Adding some ram would be a far more effective fix than defragmenting the swap file. Some 10 years ago virtual memory was just a fact of life, but the days of expensive ram are behind us now.

author: Deepak
author_rank: Regular Contributor
timestamp: March 31, 2012, 12:01:34 am
content: Quote from: benemorius on March 30, 2012, 10:02:22 pmHaving the swap is ideal because the OS was designed to have it.Ram is cheap, so the classic concerns about not having enough room for your programs are somewhat lessened. Some programs do act delinquently so a little insurance can't hurt since disk is even cheaper.One thing to keep in mind is that the amount of memory programs request can often end up being much more than they actually use. If you only have ram then all of the committed (but unused) memory needs to be reserved and cannot be allocated for anything else. If swap exists then the commits can be reserved on disk without a penalty since nothing is actually occupying that memory.The obvious response is 'who cares? I already have more than enough ram for my programs.'The thing is that uncommitted ram can be used for file caching, which can be a huge factor on performance, so by having your unused ram also be uncommitted you're getting the most out of the resources you have on hand. There's always some upper limit on how much ram you can get without upgrading boards or getting prohibitively expensive, and so when keeping the hardware invariant having swap is always better (especially when you don't use it!)

author: Lightages
author_rank: Unknown
timestamp: March 31, 2012, 12:05:06 am
content: Quote from: Rerouter on March 30, 2012, 08:56:55 pmYou are correct. I was thinking still of the days I assisted people who ran XP and some had rather small hard drives so there was an incentive to keep the swap file smaller.

author: benemorius
author_rank: Regular Contributor
timestamp: March 31, 2012, 12:52:01 am
content: Quote from: Deepak on March 31, 2012, 12:01:34 amHavingsome configured is ideal;usingit is not.The suggestion to take home is not that you should configure your system for no page file, but instead that you should ensure that you have enough ram for the amount of multitasking you commonly do so that actual swap use is not a regular occurrence. Needing to go out to ram to find your data is bad enough, but having to go all the way to a mechanical hard drive to fetch memory is completely insane.If you're noticing the performance hit of swap use, that's a sure sign that a ram upgrade would result in a perceptible increase in performance. For a much more empirical indication, I'm sure that the task manager in windows will show how much swap is in use. It's normal to see a small amount always in use, but regularly seeing more than a few hundred megs is indicative of actual swap use which could be avoided.Quote from: Deepak on March 31, 2012, 12:01:34 amQuoted for truth! For several years I ran a desktop (which admittedly had greatly more ram than I needed at the time) without a swap partition and the only time the ram came anywhere close to 0% free was during and after long rsync operations. Life was good, but then one day I started using google chrome. A month or two later it had gobbled up some 5 or 6 gigs of ram and I woke up one morning to find x in a partially crashed and unrecoverable state.I still can't be bothered to devote a whole damn partition to swap, but I certainly do keep a swap file now for when accidents like this occur. Since then it has saved me from countless dozens of similar bad days.

author: robrenz
author_rank: Super Contributor
timestamp: March 31, 2012, 12:56:28 am
content: Thanks everyone for all the help. I am good so far except I can't find the pagefile to delete it.Is named pagefile? because a search for pagefile* does not show anything. I have "show hidden files" set in all folders. My C drive is my system drive and it is not shown. Is it in a sub folder in C? Thanks again.

author: Psi
author_rank: Super Contributor
timestamp: March 31, 2012, 01:03:59 am
content: Quote from: robrenz on March 31, 2012, 12:56:28 amYou have to go one step further than 'show hidden files', you need to untick 'Hide protected operating system files'.Most of the time you will find pagefile.sys it in the root of your main disk.

author: SeanB
author_rank: Super Contributor
timestamp: March 31, 2012, 11:23:10 am
content: Pagefile should be fixed in size, preferably to 2.5 times physical memory ( worked from win9x, and still works well) and should be contiguous. As well look at the Microsoft Sysinternals site ( good set of really fast, do as they say and work totally inside windows with the cost of free being the best tools) and install the registry defragger, as this will make a difference on the way windows runs.Swapfile for me is a partition, and is much bigger than main memory ( 3 times in my case) as then hibernation is faster and will work. I did use an old small SCSI drive as dedicated swap file until it eventually died, as it was a non contented bus that improved operation.