31 Dec 2009

virtual memory

When Windows XP runs out of memory, the 128MB or 256MB or even 512MB that you have in your PC, XP needs to shuffle things around quickly. That shuffling is called paging, and it’s accomplished by copying blocks of memory out to your hard disk.

Think of it this way. Many different programs are running on your computer at the same time. Each needs memory in order to accomplish its tasks. When programs want more memory, they ask Windows to hand some over. When programs are finished with a chunk of memory, they hand it back to Windows. Your memory rapidly turns into a patchwork quilt of chunks, with Windows taking care of parceling out chunks of memory when they’re requested and returning them to the available pool when they’re no longer needed.

Everything goes along swimmingly until Windows runs out of chunks of memory. Suddenly a program wants more memory, but Windows has already handed out every single chunk. Windows solves the problem by taking a snapshot of a chunk of memory and tossing that snapshot to the hard drive. It then gives the chunk of memory to the program that requested it.

At some point, the program that originally had the chunk of memory wants it back. No problem. Windows runs out to the disk, retrieves the snapshot, sticks it in memory, and hands that chunk over to the old program. (I won’t mention the fact that bringing the snapshot into memory may, itself, force Windows to take yet another snapshot and send it out to disk. And so on. But you get the picture.)

The snapshots of chunks of memory out on your disk are called virtual memory. Virtual memory sits in paging files. Here’s where speed comes in. Windows works like crazy getting programs and their data into the computer. It also works like crazy keeping the virtual memory going. If your

virtual memory sits on the same disk as your programs and data, Windows has to hop all over the disk to keep all the programs going. On the other hand, if your paging file sits on a hard disk that doesn’t contain your programs, that helps solve the memory problem, simply because Windows can run faster if it’s juggling two different disks at the same time. The net result is that you should allow Windows to use all your fast hard drives for virtual memory (paging files), providing the drives have room available.



No comments: