What exactly does ram get used for? [closed]

There is an analogy I use when describing how the whole CPU/RAM/Hard Drive system interacts, I will do the whole analogy and it covers more than just ram, but I think it will help out.


Imagine your computer is like a kitchen, and running a program is like making a meal.

If you had two chefs (multi-core processor) you could make some meals faster, one person could cut the carrots while the other person peels the potatoes. However some points of the recipe there are things only one chef can do, for example mixing everything in the stand mixer. It does not matter if you have 1 chef or 4 chefs it still takes the same amount of time to mix the ingredients. This is why you just can't multi-thread everything, some steps take time and it can't be split across processors.

Now on to Memory:
The fastest kind of memory are CPU registers, they are like your cutting board. It is very small and can only hold what you are currently working on.

If something is not right in front of you, where do you go? You go to the pantry and get it, this is the CPU Cache. You have not left the kitchen but you did have to stop what you where doing for a few seconds and take some time to walk to the pantry and get you want.

But what do you do if the thing you need is not in the pantry? Well, you go to the corner store down the street, this is your RAM. Now it takes a few minutes to leave the kitchen (CPU) and drive to the corner store (RAM) and is 100's of times slower than walking to the pantry inside the kitchen, but your pantry is a limited size and you can't store everything in there. (Dual-Channel memory is like driving two cars to the store, you can take twice as much back home with you so you don't need to take as many trips)

But the corner store is just that, a small corner store. What do you do if you need something the corner store does not stock? Well you go drive in to town and go to the big Mega-Mart, this is your Hard Drive. Now the Mega-Mart is huge, you could get almost anything there, but there are drawbacks. The Mega-Mart is miles away compared to the corner store, and takes an hour to drive there and the employees there don't care and are very slow to check you out, it is 100's of times longer than going to the corner store (RAM) and 100,000's of times longer than just walking to the pantry (CPU Cache). And all this time your recipe (Program) is sitting there waiting for you to get the necessary ingredient to continue.

But what about those things that are super special order that even the Mega-Mart does not have it? Well you go and have it mail ordered and wait 1-3 days for it to show up, this is getting something from the internet. compared to waiting the few seconds to go to the pantry, that is an eternity.


RAM is used to store everything that is being "currently used" by the computer. For example, the parts of Windows (Or Mac OS, or Linux) that give you the desktop, file viewing and so on. The browser you are using now is loaded into memory. Ideally when you quit a program it is completely removed from memory, but some times this does not occur and causes a memory leak.

To answer your specific question, small programs are generally loaded completely into memory, but in some cases, especially with large programs, only the main parts and some important subparts are loaded always, if you call on a little used part of the program, it might have to read that into memory separately.

Also, sometime programs will get "pre-loaded" by the operating system (Windows, Mac OS, Linux, etc.). This means that the program is sitting in RAM, waiting, so when you open it, it's right there and doesn't have to be read into memory. The OS does this if it thinks that you will soon want to open that program.

Confusing things even further, if you need more memory than you actually have, the operating system will take some of your hard drive and make it act like RAM. This is called "swapping" or "paging", and the part of the drive that is used for this is called "swap space" or a "swap file" or "paging file".

(Credit for the last two paragraphs goes to Darael for suggesting them)

Someone correct me if this isn't accurate and I'll revise this answer.