Data: Storage and Memory
Before we look at Storage, Memory, and the CPU, we should first see how they all act together. Understanding these elements can give you a much better understanding of why things happen on your computer.
Storage vs. Memory
There are two ways of keeping data: in memory and in storage.
Memory is temporary storage. It includes RAM and parts of the CPU. It will keep data as long as power is turned on. However, if power is lost or turned off, the memory clears and the data is lost. This is called volatile. Have you ever heard of a computer losing power, and someone lost an hour's worth of work? That's because the data was only volatile memory.
Storage, on the other hand, is more permanent. It keeps data for long periods of time, even without power. This includes hard disk drives (HDD), solid state drives (SSD), USB flash drives, optical media (CDs, DVDs, Blu-Ray), and more. If you save a file to storage, it is much more safe from data loss.
Generally speaking, memory is fast, and storage is slow. Speeds vary, but this basic fact stays the same.
From Storage to Memory
When you turn your computer on, it takes time. If you have a fast new computer, it might be as little as 20 seconds. If you have an older slow computer, it could take a few minutes. The question is, why does it take any time at all? When you turn on most things, they begin working immediately.
Computers can only work when the CPU has access to the software (operating system and applications). However, because the CPU and its memory are volatile, they are always blank when you start your computer. To begin working, they must get the software from storage. There is a large amount of software that must be transferred. Storage, additionally, is slow. This is what takes so long.
How Data Moves
Below is a chart showing how data moves in a computer. The diagram is much simpler than reality, but gives you the basic idea.
Data begins in Storage. When you turn on your computer, the essential parts of the operating system must be sent to the CPU. Data travels along the paths, called buses. Data travels through the chipset (which manages the flow of data), and then to the CPU. In the CPU, most of the work is done in the core, where the software instructions are processed.
However, the CPU cannot hold much data. The CPU has small memory areas called cache, but these are only a few megabytes. Therefore, most of the data is sent to RAM, which can hold gigabytes of data. If there is not enough room in RAM, data will be kept back in Storage—but because storage is much slower, this will begin to slow down your computer.
For now, ignore the external devices (peripherals) and the PCI Express (used for high-speed graphics), and look at the more basic path of the data:
As you move from storage to the CPU, capacity decreases and speed increases. Storage can hold terabytes of data, but is slow; RAM can hold gigabytes of data, and is faster. CPU cache is smallest, holding only megabytes of data, but can access data the fastest.
To get a better feeling for what is happening, think of this process as baking cookies.
You decide to bake some cookies, but you do not have any ingredients in your house. Therefore, you must go to the supermarket and get what you need. The supermarket is big, but is not very close. It takes a long time to get there, and a long time to find and collect all the ingredients you need. You don't want to have to make extra trips to the supermarket!
When you get home from shopping, you have to put away the things that you bought. You put the butter and eggs in the refrigerator, and everything else—the flour, sugar, chocolate chips, and so on—into cupboards.
When you cook, your kitchen counter is not big enough to hold everything at one time, so you only get a few ingredients at a time, use them, and then put them back where you got them.
When you have ingredients on your counter, you can access them one at a time and add them to the mixing bowl.
When you do this, it is very similar to what a computer does:
When you turn on your computer, it goes to the "supermarket" (the hard drive), which is far away and large, so it takes some time.
When the data is brought to the CPU, the CPU "puts away" the data in the "refrigerators and cupboards" (RAM).
When the CPU needs to do something, it brings the essential parts onto the "kitchen counter" (the CPU cache).
The CPU then takes each instruction into the "mixing bowl" (CPU core) to process it. If it needs to use the data frequently, it keeps it in the CPU cache; otherwise, it will send it back to RAM.
Whenever you save a document, you are sending the data back to the Storage area.
Have you ever used a computer that is fast at the beginning, but after you open up too many programs, it really slows down? That is usually because there is not enough RAM.
Let's say that your computer has only 2 GB of RAM (too small for today's computers). You open the operating system, and that takes up 1 GB of the RAM. It's half full. The computer is still fast.
Next, you open up a game. It uses 500 MB (half a GB) of RAM. Your computer is still OK.
Next, you open up a photo editing program. It uses 600 MB of RAM, a little more than half a GB. You are now over the limit, but your computer is still OK. It uses some tricks to open up RAM space, like putting unused data back on the HDD. Your computer may slow down a little, but it still seems to work OK.
However, you then open up a browser, like Safari, which tries to open 10 web pages in tabs that you were viewing when you last quit the browser. It tries to use almost a whole GB of RAM. Suddenly, your RAM has no space, and the HDD must be used more.
Your computer now slows down and you get the "wait" cursor.
The problem: your computer does not have enough RAM.
I always give people the same advice: when you buy your computer, get more RAM that you think you need. If possible, double the amount of RAM. You may not need it today, but there will come a time when more RAM will make a huge difference in your computer's performance.