| Do We Still Need A Swapfile? Even
today, although the average home user's computer comes with at
least 64MB of RAM, a swapfile is still very important. While the
large amount of RAM in the average user's computer meant that
memory shortage while running any one program is much less of a
worry than it was back then, the swapfile is essential when
multi-tasking.
Note that over the years, the emphasis has changed to
multi-tasking. No longer will people be solely stuck to using one
application at a time. In fact, it's common to have 5 or more
applications running simultaneously! For example, while browsing
the Net, I normally have 4 Internet Explorer windows (loaded as
separate processes), a FTP client, ICQ, a download manager like
GetRight, FrontPage 2000 and WinAmp running at the same time with
a couple of Word documents opened. That's a total of 8-12
applications running simultaneously!
Even with 128MB of RAM, it would be impossible to load
everything into the RAM. Thus, a swapfile is needed to store the
least used data in the memory so that I can open up all those
applications I need. And let's not forget the disk cache.
Operating systems like Win9x and Win2k 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 swapfile,
you won't be able to open many applications even if your computer
has 64MB of RAM.
Finally, some programs require the use of a swapfile to
function properly. It may be to store sensitive data on something
less volatile than the RAM or to ensure the computer will have
sufficient memory to run it. But whatever the reasons, a swapfile
is needed in order for these programs to run.
But Why Optimize The Swapfile?
Unless your computer is truly loaded with RAM, it will almost
always use the swapfile. As such, its performance affects the
performance of the whole computer.
Now, using a swapfile may sound like a really cheap way to run memory intensive programs
without the expense of buying more RAM. However, even the fastest hard disk is
more than an
order of magnitude slower than the slowest RAM. Numerically, the fastest
hard disk is currently 20X slower than the PC100
SDRAM common in many computers. Let's not even start comparing the
hard disk with faster RAM solutions like the PC133 SDRAM or the
PC266 DDR SDRAM. :)
So, swapfile is only a stopgap solution for the lack of sufficient RAM.
As long as you use the swapfile, there will always be performance
degradation. The ideal solution for insufficient RAM is always more
RAM, not more Virtual Memory. But since we can't afford all
the RAM we want, a swapfile is necessary to allow us to run today's memory guzzling
programs.
As you can tell, more isn't better for the swapfile because more swapfile space will
only give you the ability to run more memory intensive programs at once. It will
not speed
up your system. But what we can do is to optimize the swapfile so that the performance
degradation when using it is minimized.
So How Do We Optimize The
Swapfile?
There have been many theories on how to optimize the swapfile. The most important ones
are listed below :-
- Making the swapfile permanent
- Moving the swapfile to the outer tracks of the hard disk
- Creating a huge swapfile
- Moving the swapfile to a different partition in the same hard disk
- Moving the swapfile to a different hard disk
We will examine those methods and see what will work and what won't.
|