Just curious about it, but can’t understand why is it like that.
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.
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.”
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.
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.
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.