Why do computers need RAM memory? And why some programs require lots of it while others require less?

184 views

Just curious about it, but can’t understand why is it like that.

In: 7

15 Answers

Anonymous 0 Comments

RAM is fast memory. It’s like having a big desk to work on; having stuff be on the desk makes it easier to switch from one task to another, instead of having to go dig through the filing cabinet to put the finished work away and find the next file to work on.

Anonymous 0 Comments

So imagine you are doing a research project, but don’t have the internet available to you. You go to a nearby library. To look up information, you need to walk over to the appropriate shelf with the reference material on it, pick it up, and bring it to the table where you are doing your project.

The library shelf is your hard drive with all that information and the table is your RAM. You have a limited space on the table, but if you put the books you need there temporarily, you can have access to them quickly and easily instead of having to go to the shelf, pull the book off, look up what you want, put it back, and then walk back. The more information you need for your project, the more space you will use on the table for reference books.

Anonymous 0 Comments

Basically, the long term storage in your hard drive is very slow and the incredibly fast memory your processor can use for very short term storage is, by necessity, very limited.

Programs pretty much universally have data that they want to store to be able to access quickly. These are generally interim data the program needs in order to run right now, not things that the program wants to save for later. Oftentimes the amount of data needed is quite large. RAM is purpose built to fill this role: fast to access yet relatively abundant.

As for why some programs use more or less, it really depends. Some programs need to store a lot more data in order to function. Your high end video game needs to store a lot more data than a plain text document. However, it’s often just a choice by the programmer (i.e., ‘my program will use lots of memory but that’s ok due to the context it will be run in’) or just simply the programmer caring more or less about how efficiently the program uses memory. There may be very compelling cost or efficiency reasons to build software that uses lots more RAM than it “should.”

Anonymous 0 Comments

Programs all operate on data. Numbers. Your game, with all its polygons and textures, are at the end of the day a collection of billions if not trillions of numbers. All of your text in your browser are numbers. The youtube video you are streaming are all numbers.

Some programs need less and others more because they need different amount of numbers to do what they do. A computer has multiple places it can store those numbers. Like your SSD or HDD. The problem is that things like that are really slow. At least compared to RAM. RAM is like your SSD/HDD but hundreds or thousands of times faster. Without it, your program will be really slow.

Anonymous 0 Comments

Some things you hold in the back of your brain, like your birthdate and fond memories. Other things you need right now but then forget about right away like if you’re trying to calculate (35*6+4)/2. You do the multiplication in your head but once you’re done multiplying and adding you don’t need to remember any of those terms for the division and you can safely forget about them even if you want to keep the answer. The storage drives in a computer are like your long term memory and the RAM is like your memory for the stuff you need to remember right now but not after you’re done with them. Some things you need to remember right now are complicated and some computer tasks also take a lot more short term memory than others. If a computer runs out of short term memory it can store stuff in the storage drives but it gets very slow when it does this.

Anonymous 0 Comments

You do work at your desk, lots of paperwork. Your desk is only so big, so you can only have so many papers on your desk at one time. If you need more space, then you have to take a paper from your desk, put it in the filing cabinet, and get another paper you need. Things get really slow if you have to do this too often.

Say your workload is some basic accounting. You need a good number of documents to do this, but you can all fit them on your desk. You’re good. You pull all the needed documents from the filing cabinet, you work on them, you put them back, and you get the next set.

But then you get an account for a millionaire with very complex finances. You can’t fit it all on your desk anymore. You have to keep going back and forth to the file cabinet in order to figure it all out. You can do your work, but you could do it more quickly if you had a bigger desk.

Then an electrical engineer takes over your desk. It’s not even big enough to hold just one of his drawings. He simply can’t do his job. Maybe he could cut up the drawings and be constantly on the run ferrying pieces of the drawing between the desk and the filing cabinet, but that’s not a good way to work. He needs much more desk space.

Desk is RAM, filing cabinet is disk.

Anonymous 0 Comments

OK, think of how we looked up information before computers.

You have questions and the encyclopedia at the library has answers. An encyclopedia can come in 22 volumes, each a separately bound book.

You have checked out volume “A” which contains all encyclopedia topics that start with the letter “A” and brought it back home.

(I’ll put the computer analogy in parentheses.)

You open the book

(start the program which loads the book contents from disk into RAM)

to an article about Aardvarks. You read that page.

(This is like reading data in the CPU L1 cache.)

The article continues, so you turn the page.

(This is like reading a page of data from the CPU L2 cache.)

But now you are curious about anteaters. So you go to the index and look up which page starts the anteater topic (page 328) and you turn to that page.

(This is like reading from RAM. The more RAM, the more pages you can have in the book.)

Anteaters are interesting, but **pangolins are cool**.

Except you don’t have encyclopedia volume “P” at home. So you go to the library to return volume “A” and ask to check out volume “P”.

(This is like getting data from disk. A bigger disk can store a bigger library of books.)

Except the librarian tells you that volume “P” is already checked out to Chad. You now have to wait until Chad returns that book before you can check it out and read it yourself. That might take a while.

***Chad!***

(This is like downloading data from the Internet where the request comes from your computer, to the ISP and on to some server, and the resulting data is sent by the server to your ISP and on to your computer.)

Knowing about pangolins is worth the wait. But if you had ~~more RAM~~ a giant encyclopedia, you could have had all topics in one volume and been learning about pangolins right now.

Anonymous 0 Comments

CPUs will perform a certain sequence of calculations every clock cycle. We ideally want memory fast enough such that the CPU can retrieve the data from it within a clock cycle.

However, due to material, space and power constraints, we can’t solely use the super fast memory (the super fast memory typically being L1 cache, which can be accessed within 1-2 clock cycles).

Therefore we established a hierarchical memory structure:

1) L1 cache (few hundred kilobytes, fastest)

2) L2/L3 cache (tens of megabytes, extremely fast)

3) RAM (gigabytes, fast)

4) storage drive (terabytes, slow)

As to what the RAM is used for, it’s whatever data the application you have opened need to store, for a web browser it would be webpages (HTML, Javascript, media content), the sandbox environment the webpages run in and user interface icons.

A game would need to store object data, the game’s code, sounds and textures not currently in VRAM but might need to be used soon.

There are algorithms such as First In First Out that determines what data should go where, since we want the frequently used data inside the L1 cache and the less frequently used data inside the RAM.

In large datacenters such as Facebook or Google, they also develop caching algorithms to allocate data between fast SSDs and slower HDDs for the sake of faster transfer to the client. The goal is to predict what data might be needed soon/more frequently and move them to the SSD.

Anonymous 0 Comments

The CPU can only be used with a program, data that will literally instruct it what to do. The CPU makes a clear distinction between memory that serves as a program and data that will be processed (e.g. “an image”). Physically, it uses the same RAM. A computer has (part of) the program and (part of) the data in RAM.

A computer will use more memory when there is a lot of data to process (e.g. a video) or when the program is big. Sometimes the data is already bundled with the application (e.g. with fonts or error messages) and sometimes this comes from other sources (e.g. the internet or disk).

Then there is the concept of cache. Cache is memory to temporarily store data or program (in order to avoid the costly endeavor of getting it from its slower source like a disk). RAM is often used as cache too.

The result is that, after a while, most computers use all memory available for the above functions: cache, program and data.

Anonymous 0 Comments

Think of a kitchen:

The fridge is the hard drive, it stores things for the long term.
The kitchen counter is memory.
The cook is the CPU.

Can the cook make a meal directly in the fridge? No, the fridge is made for holding lots of ingredients, not for chopping and mixing.

The cook needs the kitchen counter to cook the ingredients from the fridge. It first gets the ingredients from the fridge (hard drive), works with it on the counter (memory), and delivers the meal/result (output).