Training
Certifications
Books
Special Offers
Community




 
Faster Smarter PCs
Author Scott H. A. Clark
Pages 320
Disk N/A
Level Beginner
Published 11/13/2002
ISBN 9780735618558
ISBN-10 0-7356-1855-0
Price(USD) $19.99
To see this book's discounted price, select a reseller below.
 

More Information

About the Book
Table of Contents
Sample Chapter
Index
Related Series
About the Author

Support: Book & CD

Rate this book
Barnes Noble Amazon Quantum Books

 


Chapter 3: Working with Memory



Chapter 3   Working with Memory

Memory is probably the most useful and least understood resource available to your PC. It's a limited resource, but it's infinitely reusable. At any given moment, you could run out of memory. But you'll never have to buy a new collection of memory because you've slowly depleted your available supply, as if memory were really like a scratch pad or a sticky note. And once you use some memory, you don't have to move on and use different memory, as if memory were really like an unpainted house or a canvas.

Why all the analogies, anyway? The conclusion I've come to is that folks have decided that memory is one of those complicated parts of the PC. People who do know a lot about memory seem to turn to the endless list of "it's like." because they figure you don't really want to know, and you don't really have the time to get it.

All of which is nonsense, as you'll soon see.

What Is Memory?

Memory is the electronic space where your PC works. It is a collection of specially designed microchips that plug into your PC's motherboard (and a few other places), which the PC uses to store your programs and your data temporarily while you're using them. I say temporarily because memory is different from storage—a difference that lots of people miss. While your PC is powered on and you're running an application, the code that makes the application work is in memory. If your PC suddenly turns off, everything in memory is lost forever.

But you know from experience that you don't lose software every time you suffer a power outage, and you can keep data for years by saving it in files. You don't lose programs and files because they're kept in storage—on your hard disk. When you start an application, it's simply copied from storage (your hard disk) into memory. When you open a file, a copy of the file goes into memory, and you work with the copy that's there. When you make changes and save the file again, the data is copied from memory out onto your hard disk—from memory back to storage.

Normally, you can't lose the work you've saved to storage even though everything in memory is lost when your PC turns off. Similarly, when you close a file or quit a program, any work you saved to storage is kept—as is the program you were running. Any data you don't save is removed from memory and is gone. Of course, you can still lose data you've saved due to a hard disk crash, but generally you can consider it "permanent."

You don't need to understand how memory works electronically to get the most from it. What is useful is having two other bits of knowledge: how the PC uses memory and why memory comes in a variety of types.

How a PC Uses Memory

Entire books have been written about the full story of how the PC uses memory. Fortunately for you and for me, this isn't one of them. (Nothing is worse than writing a book you'd never choose to read!) The full story of how a PC uses memory is, as Victor Borge said about the history of the piano, "quite uninteresting." What's important about memory is that memory and the CPU work together to make the PC a "thinking" machine.

Bits and Bytes

Your PC doesn't communicate in the same way you do—but like you, it has a language. I'm not talking about all the different computer languages you hear about, like C#, C++, or Perl. Those are just specialized human languages that make it easier for you to tell the computer what you want it to do. The only language your PC understands is a binary machine language consisting of two numbers: one and zero.

This is because your PC is one of millions of digital computers. Put simply, your PC works with specific and regulated amounts of electricity, which you can think of as being either on or off. The physical microchips that provide your PC's memory are actually just huge collections of transistors and capacitors. The capacitors function like bottles of electricity that can be either full or empty.

Whenever a capacitor is given a bit of electricity to hold (the bottle is full), we symbolize that with the number one. Whenever a capacitor is holding no charge, we symbolize that with the number zero. Everything in your PC comes down to ones and zeros. Just as human language gathers letters into groups of sounds and groups of sounds into words, the PC organizes all the ones and zeros together into chunks. The most basic chunk of one-or-zero values your PC uses is a short string of only eight of those values. These eight values (ones, zeros, or a combination of the two) collected together are called a byte. Each of the eight values that make up the byte is called a bit.

Bytes make up the building blocks of everything your PC accomplishes. What sets one byte apart from another is how they are used. The right collection of words is a Shakespearean sonnet; the right collection of bytes is a photo of Rover. Your PC must use bytes properly to make sense of them. Try to look at a photograph by opening it with an application designed to edit electronic music, and you won't see your pooch or hear any glorious melodies; you'll get nothing at all, because most modern software will politely refuse to work with an inappropriate collection of bytes.

When you talk about your PC's memory capacity, you're talking (roughly) about how many bytes it can work with at any given time. (As you'll see, your PC might be able to work with far more bytes than are strictly available in its memory chips.) The original IBM PC had 640 kilobytes (KB) of memory—meaning that it had the capacity to store roughly 640,000 bytes in its memory chips at once. We often use the shorthand letter K to indicate 1000 of something, and you'll encounter that symbol throughout this book.

Another bit of shorthand you'll see often is MB, which means megabytes, or millions of bytes. If your PC has 256 MB of memory, its memory chips have the capacity to handle roughly 256 million bytes at once. And your PC's memory chips are usually just called RAM, pronounced like the name of the animal. Random access memory (RAM) simply means that your PC can instantly access any byte that's held in it, without first looking through all the bytes that are being used. So 256 MB of RAM is the same as 256 MB of memory. (Remember, though, that RAM has nothing to do with your PC's storage capacity. RAM, or memory, is just the temporary electronic space your PC uses to work.)

To give you a frame of reference, the Microsoft Word file that contains the text and pictures of this chapter uses about 921,000 bytes (that's 921 KB). A high-quality digital photograph generally fits in a file that holds 6 million bytes (6 MB). As you open multiple files, your PC must have enough memory to hold the code of the application you're using to view the files, plus all the bytes in the files themselves.

Memory Types for Every Need

Your PC uses several different types of memory to support its different needs. For example, RAM, which you've started to learn about, is flexible and changeable. Within the RAM family, lots of different types exist. Your PC also uses read-only memory (ROM, rhymes with "Tom") to store permanent information that can't be changed. ROM also comes in several types. This section takes a look at these different types of RAM and ROM. You'll likely encounter them when you buy or upgrade a PC, and you'll definitely come across them in articles and reviews of PC hardware innovations and options.

Dynamic RAM

Your PC's main RAM is a specific type of memory called dynamic RAM (DRAM), shown in Figure 3-1. By design, immediately after data is sent to this type of memory, the DRAM (pronounced "dee-ram") begins to lose, or "forget" it. To solve this rather significant problem, a bit of circuitry called the refresh reads and rewrites the value of every DRAM capacitor (which I'm going to call a cell, just for simplicity and because you might hear that term).

Click to view graphic
Click to view graphic

Figure 3-1   DRAM provides the main memory for all modern PCs.

How fast do DRAM cells lose their contents? That rate is part of the specifications you'll encounter when you purchase memory. It's measured in nanoseconds (one billionth of a second), written ns. A DRAM chip that is rated at 40 ns refreshes its values once every 40/1,000,000,000 of a second. And you thought you had a short memory!

As it turns out, the shorter a PC's memory is (that is, the faster its capacitors lose their charge), the better the memory (and the more expensive) because a DRAM chip's refresh rate is also the fastest speed at which the bytes it's storing can be modified. Faster RAM is better because it enables your PC to perform tasks ever-faster. This speed is one of the reasons why the memory used for high-end video cards is so expensive (as we'll see in Chapter 4). For applications that perform complex calculations, like the drawing of photograph-quality 3D models, the speed of a PC's main memory can make a tremendous difference.

Because early DRAM was not the fastest boat in the harbor, new types of memory had to be developed. Aside from certain shared characteristics, like refresh rate, one DRAM module might be distinguishable from another based on a few key features. Sometimes buying memory feels a little bit like buying a car. You might not be sure which features you want, but you can be sure the salesperson will know what he or she wants to sell you. So let's put all of the jargon and features in their place. You can be comfortable in the world of DRAM in just a few minutes.

Synchronous DRAM

Synchronous DRAM (SDRAM) is the most common type of RAM in PCs today, but SDRAM isn't one specific type of DRAM. Instead, it's a family that includes the original—now old-fashioned—SDRAM, and several newer, faster offspring. If you find memory modules for an amazing price that are simply identified as SDRAM, the low price is most likely because these are antiquated chips. Today's power-memory SDRAM goes by the name double-data rate (DDR) SDRAM, which is illustrated in Figure 3-2.

Click to view graphic
Click to view graphic

Figure 3-2   DDR SDRAM is the most recent innovation in mainstream PC memory.

DDR SDRAM

Double-data rate (DDR) RAM—properly called DDR SDRAM—was something of a revolutionary development. To explain why, I need to digress for just a moment and talk about clocks. If you listen to an old pendulum clock or a wristwatch, you hear the familiar tick-tock sound. The timepiece actually makes two sounds—one tick, one tock—each second. The PC's system clock doesn't make any sounds, but it "ticks" and "tocks" electronically, so to speak. In fact, the PC clock is just an electrical circuit that regularly switches from passing a higher voltage to a lower voltage and back again. One complete cycle (low-high-low) of voltage changes is the pattern that defines a clock cycle.

So what does all this have to do with SDRAM? It's like this: Whereas regular SDRAM works on full cycles, DDR SDRAM, shown in Figure 3-2, works on half cycles. That is, it can store or retrieve a value with each "tick," and it can store or retrieve a value with each "tock." This double-data rate, which leads to much greater speed, gives DDR its name. I've illustrated this idea in Figure 3-3.

Click to view graphic
Click to view graphic

Figure 3-3   SDRAM accesses memory contents on each full clock cycle; DDR SDRAM works on half cycles, making it twice as fast.

A PC must have both a motherboard and central processing unit (CPU) designed to work with DDR SDRAM to benefit from this potential. This requirement is a bit of the balanced integration I introduced in Chapter 2. Recall that I mentioned pipelining, which at the simplest level is a way to break CPU instructions down so that several instructions can be executed in parallel (meaning that several instructions are completed, on average, in each tick of the clock).

Some processors, including the Intel Pentium 4, do pipelining tasks so that the CPU benefits from the double-speed potential of DDR SDRAM. If we say that "at once" means a single tick of the system clock, we can say that the Pentium 4 can perform two (or more) tasks at once. DDR memory can also perform two tasks at once, in this sense, so this type of pipelining and DDR are a great team. Other types of pipelining work differently and use DDR's capabilities less efficiently.

When you select DDR SDRAM, you must consider more than just your CPU, however. The world of DDR is full of even more jargon intimately related to its performance. Terms like PC1600, PC2100, and PC2700 are just the latest in what will surely be a long line of lingo. The numbers tell you the maximum speed at which the memory modules can move data. The PC1600 can move 1.6 billion bytes—that is 1.6 gigabytes (GB)—of data per second; PC2100 can move 2.1 billion bytes (2.1 GB) per second, and so forth.

Unfortunately, these numbers—chosen to be impressive, not informative—don't really tell you what you need to know. You need to know whether a given model of memory will work with your motherboard. So here's a bit of translation.

When You See DDR SDRAM Labeled.Look for a Motherboard That.
PC1600Has a system bus (or front-side bus) speed of 100 megahertz (MHz) and a 200 MHz data rate.
PC2100Has a system bus (or front-side bus) speed of 133 MHz and a 266 MHz data rate.
PC2700Has a system bus (or front-side bus) speed of 166 MHz and a 333 MHz data rate.

Most modern motherboards are capable of supporting several different bus speeds, depending on which CPU and memory you install. You'll want to carefully coordinate these three pieces of hardware when you make a purchase.

Video RAM

Specialized memory for high-end and 3D accelerated video cards is sometimes called video RAM (VRAM) or Windows RAM (WRAM). We'll look at this type of memory more in Chapter 4, but its primary feature is its ability to respond to read or write requests from more than one part of the PC at once. In this way, part of the VRAM can be putting a complex 3D image on the screen while another part of it is already in the process of receiving the data necessary to generate the next image that should be shown. This functionality makes for some dramatic performance improvements, leading to more lifelike animation.

Static RAM

Yet another type of RAM, quite different from DRAM, is called static RAM (SRAM), and it's a lot faster than dynamic RAM. Therefore, SRAM is used in CPUs for the cache memory that you read about in Chapter 2. SRAM uses complex combinations of transistors to store its contents.

Because of its design, SRAM maintains its values so long as power is applied to the SRAM module. SRAM contents don't slowly drain away like DRAM contents do, so SRAM never has to be refreshed. Sending the correct set of signals to a group of transistors changes their stored value instantly. So why isn't every bit of your PC's memory provided by SRAM? Cost—SRAM is many times more expensive than even the most expensive DRAM. It is best used in small quantities for special purposes where absolute performance is mandatory.

Read-Only Memory

ROM is another type of memory used in every PC. The data stored in ROM can never be changed. When it is created at the factory, it already contains the values it's expected to maintain, and it keeps those values even when the power is turned off. Because of this, we say that ROM is nonvolatile memory (as opposed to RAM, which loses its values when power is lost, and so is volatile).

If it can never be modified, what good is ROM? The fact that it works the same exact way time after time is useful for two reasons. First, a ROM chip takes up a lot less space than would all of the full-size transistors and diodes and other electronics necessary to wire comparable permanent functions. Second, ROM chips make it possible for a manufacturer to use the same basic design for different products. Your VCR and your DVD player, for example, might have remote controls that are exactly alike, except that in one, the ROM chip contains instructions for controlling the DVD player.

In a PC, regular ROM was originally used to store the most fundamental instructions required to get your PC working when you turned on the power. These instructions form the basic input/output system (BIOS), which controls the PC from the moment power is applied until the PC's operating system can be accessed from a storage device and made to start up. Today, your PC's BIOS is not stored in this kind of ROM. Instead, a special kind of ROM is used which, paradoxically, can be modified.

Electrically Erasable Programmable Read-Only Memory

This specialized ROM goes by the name electrically erasable programmable read-only memory (EEPROM). I'll admit, the name doesn't make a lot of sense on its own, because it basically means changeable unchangeable memory. But the name fits because that's exactly what EEPROM is. Normally, EEPROM behaves exactly like ROM. You can turn the PC's power on and off repeatedly, and the values in EEPROM won't change.

However, EEPROM chips are designed with a controller which, after receiving a specific series of instructions, allows the data stored on the EEPROM to be changed. This set of instructions is usually sent to the controller as electrical signals generated by a small program you run. EEPROM is now used to store your PC's BIOS code because it's sometimes necessary to update that code to support new technologies. Then a motherboard manufacturer that updates its BIOS can just post the new code on its Web page. You can download and save the code to a bootable floppy disk, restart the computer using that disk, and then run the program you downloaded.

SmartMedia cards and CompactFlash (shown in Figure 3-4) are specialized EEPROM cards, known by the collective term flash memory. Each of these cards uses proprietary methods to store and modify data in memory that maintains its contents, even when the card is removed from its host PC or handheld computer and power is lost.

Click to view graphic
Click to view graphic

Figure 3-4   A CompactFlash card contains a specialized type of EEPROM memory chip.

How Much Memory Is Enough?

After deciding which type of memory to purchase for your PC, you need to determine how much memory you need. But how do you decide? The "correct" answer depends on what you've got and what you want to do. First, looking just at memory, how much is enough?

Consider What You've Got

Think about the hardware and software you own. The principle of balanced integration says that if you've purchased a fast CPU and motherboard, it makes no sense to purchase just a tiny bit of memory. Because the PC uses memory to temporarily store everything it's working on, you need to have enough memory to complement the power of your CPU. If you don't have enough actual memory, your PC will attempt to compensate by using a system called virtual memory, which is much slower than the real thing. You'll never reap the benefits of that amazing CPU if you don't give your PC enough electronic elbow room.

Also consider your video card (or the video system built into your motherboard). With some video support, the cost of the card or the motherboard has been reduced by not providing any dedicated video memory. In that case, the memory needed to put images on your screen (more about this in Chapter 4) will come from your PC's main memory. In essence, part of your main memory will be set aside and dedicated to video-specific tasks. Naturally, dedicating some of your memory to one task removes it from the available pool of RAM. If you start out with too little memory in the first place, this is a recipe for disaster.

Now, if you've purchased a lot of high-end, fast-performance hardware, you're likely the kind of person who's going to push your PC to its limits. So having taken the actual hardware into consideration, let's look at the software you intend to run.

Consider What You Want to Do

Every piece of software you run, including your operating system, has a set of minimum system requirements (MSR): a short list of the resources your PC absolutely must have for the product to work. (Mind you, I didn't say work well.) Always focus on the word minimum when you're looking at the requirements of the tools you want to use and the software you want to run.

Let's consider Windows XP for a moment. Its minimum system requirement for memory is 64 MB of RAM. And it will run in that amount of memory, no question. But four times the memory—256 MB—costs only about $20 more at the time I'm writing this. Twice as much memory again, 512 MB, costs only another $35, and you'll get vastly more than your money's worth from that purchase. Windows XP will work better the more memory you give it.

But the amount of memory Windows XP is actually using is memory that other applications can't use at the same time. So it's not sufficient to look just at the MSR for Windows XP. Think about how you intend to use your PC. Will you run a word processor? Will you edit pictures and insert them into the term papers you're writing? Will you take advantage of your broadband always-on connection to the Internet and run MSN Messenger in the background at all times? Each piece of software you use has its own set of MSR. So, although few people do it, you could sit down and add up the MSR for the applications you know you'll want to run simultaneously and then use that as a baseline.

Some companies, like Microsoft, actually provide useful recommendations, like indicating that the MSR for Microsoft Office XP, running under Windows XP, is 128 MB of RAM, plus a minimum of an additional 8 MB of memory for each Office program you're running. You should still consider these bare minimums. Certain types of software require notably more memory than do others: AutoCAD 2002 requires 128 MB of RAM; Adobe Photoshop requires 128 MB; and popular video games often require 64 MB of RAM each.

If you'd like a rule of thumb, I generally use the same one for memory that I use for storage devices: buy the most you can comfortably afford.

Windows XP Memory Management

How does Windows XP manage the memory we give it? If an operating system doesn't properly allocate memory to applications, they won't run well. And if each application isn't given its own protected memory space, your word processor could write data into the memory being used by your financial calculator, with disastrous results. Further, if the memory a program is using isn't released when that program exits, other programs can't use that memory. So you could end up with plenty of memory installed and no applications running, but no memory available to run anything. Fortunately, Windows XP provides a solution: virtual memory.

Virtual Memory

When you can't give your PC all the physical memory you'd like, virtual memory takes up the slack. It allows the PC to use blank space on a storage device as if it were memory chips. In other words, space on your hard disk becomes an extension of your PC's RAM.

Here's how it works. When Windows XP is first installed, it checks how much physical memory is installed. It then creates a hidden file on your primary hard disk (usually your C drive) that is 1.5 times the size of your actual RAM. So on a PC with 512 MB of RAM, Windows XP creates a 768 MB file, usually called the swap file or the paging file.

As the applications you run require more memory, Windows XP analyzes which parts of program code and data in memory have been accessed the least recently. Then it copies that code and data into the paging file on your hard disk. The memory that code or data was using is released so that your RAM-hungry application can use it. This process repeats as your software requires additional memory. Should your applications need the data or the code that was relocated to the hard disk, it is moved back into RAM, swapping places with other, least-recently-used code or data there. Data is swapped back and forth as needed.

As you'd expect, virtual memory is a lot slower than physical RAM. But with your Windows XP virtual memory settings chosen wisely and properly balanced, you can easily get better performance from your PC than you would if it were strictly limited to the physical RAM installed.

Maximize Your Virtual Memory Performance

Windows XP provides a number of tools and settings you can use to tweak the best performance out of your virtual memory. Because disk storage is so much slower than physical RAM, the most important factor to consider is whether you have enough RAM in the first place. If you don't, your PC will be moving data to and from virtual memory a lot. If your hard disk sounds like it's having a conniption and everything on your PC screen is updating very slowly (or if the entire PC seems frozen), you're likely thrashing your way through virtual memory.

As usual, the bottom line is all about balance. If you want your PC faster, you need to think smarter about how it's configured. So, once you've determined that you do have sufficient physical RAM for most of your needs, you can use the following techniques to fine-tune your virtual memory performance.

Selecting a Hard Disk

If you have more than one hard disk in your PC, you should store the swap file for your virtual memory on the fastest one. You'll learn how to make this determination in Chapter 13. A point to consider now, however, is that you'll get the best speed if your swap file is on a different hard disk than Windows XP and all of its operating system files. Normally, you'll want Windows XP on your fastest disk because its files are accessed continually. Having your swap file and Windows XP on the same disk can lead to thrashing if you rely heavily on virtual memory.

A better solution is to move the swap file to a different disk, even if that disk is a little slower. If you are truly hard-pressed for virtual memory performance, you might need to consider upgrading your secondary (or third, or fourth.) disk to a faster model that is better-suited for hosting the swap file.

Dividing the Swap File Between Several Drives

An alternative way of increasing virtual memory performance—sometimes dramatically—is to put part of the swap file on each of several disks. Consider a PC that your company is using as a low-end file server for documents everyone shares. Such a PC might be equipped with six hard disks. If the PC has 1 GB of physical RAM, its swap file should be 1.5 GB, according to Microsoft's recommendations. Skipping the first disk, which contains the operating system, you could configure one 300 MB swap file on each of the remaining five disks. Windows would treat this like a single large swap file, but with a major difference.

Placing Virtual Memory on Different Partitions

Partitioning is a way to divide up a single physical hard disk so that it behaves like multiple disks. With partitioning, you can take a single 100 GB hard disk and make it function like you've actually got two 50 GB disks (perhaps a C and D disk drive).

However, partitioning isn't magic. It doesn't turn one disk into two, and it doesn't add additional read/write heads to the disk, either. Because all of a partition's space is together, partitioning one disk into two disks is like dividing it in half. The read/write heads will have to make large (read, "slow") movements each time you access data first from one partition and then the other.

Key Points

  • Memory is the electronic space where your PC works. Your operating system, the applications you run, and the data you work with are stored in memory while you're using them.
  • Memory works like the rest of your PC, by converting real-life information into a series of ones and zeros, which make up the binary language the PC can understand and manipulate.
  • Each of the individual ones and zeros that are used to represent information is called a bit.
  • Bits are grouped together into sets of eight, which are called bytes. The byte is the basic block of data in the PC; 1024 bytes is called a kilobyte (KB); roughly 1 million bytes is called a megabyte (MB); roughly 1 billion bytes is called a gigabyte (GB).
  • Main memory inside your PC is called random access memory (RAM). Your PC also contains read-only memory (ROM), which contains code and data that can't be changed.
  • Your PC should ideally contain enough physical RAM to support all the programs and data you commonly use simultaneously.
  • Windows XP provides virtual memory, which uses space on a hard disk to supplement the physical RAM in your PC as needed.



Last Updated: October 28, 2002
Top of Page