r/computerscience • • Dec 30 '23

WTF does ram actually do?

I know that RAM stores data for quick use for the CPU. But I want to know more, what does RAM actually do when its storing data. Like when I'm playing a game is RAM responsible for keeping track of how many bullets I shoot. If there are any game developers reading this please let me know. What kind of information does RAM store and how and when does it use it. The main thing I use my pc for is gaming and recording/video editing so how would RAM play a role in those things?

263 Upvotes

97 comments sorted by

View all comments

94

u/FantasticEmu Dec 30 '23

The entire process is stored in ram while it’s running m. Your game is a process, your editing software is a process, your operating system is a process

10

u/Pedro73376 Dec 31 '23

This is the most general and correct answer, but I’ll add that not only process ate stored in RAM, but also files, and directories are also files underneath, so when some line of code request something from IO that is not in l1 cache, it will require to the SO, that will cause the process to be put in hold and the processor is freed to do something else while the data is being retrieved and stored in ram, tipically the ssd’s and hdds are slower then cache in two orders of magnitude. But that is it, instructions and data are stored in RAM.

5

u/jgames09 Dec 30 '23

It can be stored partially, divided in pages. Otherwise no way would you be able to run games such as CoD lol

6

u/PaulWard4Prez Dec 31 '23

The CoD package is huge, but it’s not all in memory at once. Only the elements that are relevant to your current game context will be.

9

u/FantasticEmu Dec 30 '23

Not sure what you mean. A page is in ram. If you run out of physical memory it’s possible to cache pages in virtual memory but I believe that is outside of the scope of discussion and usually a scenario to be avoided.

The running process is what is memory while it’s running . That doesn’t mean that it has all of the data in whatver parent directory the binary is in.