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?

258 Upvotes

97 comments sorted by

View all comments

41

u/P-Jean Dec 30 '23

RAM is volatile memory that processes use to store and access information often while waiting for their turn on the processor. This info needs to be written to nonvolatile memory like your hard disk if you want to save it once the power is shut off. The more RAM that you have, the more processes you can run. They are still limited by their turn on the processor though.

9

u/siddeslof Dec 30 '23

To elaborate on that last point I have 64gb of ram and a decent CPU which means I can store that 64gb of data but still have to wait for my CPU to retrieve the data and execute any tasks before and leading to that data retrieval

1

u/P-Jean Dec 30 '23

64gb! I’m envious haha.

3

u/FluffyProphet Dec 31 '23

Ram is dirt cheap again. I had 16 and it was staring to become a problem for work. I upgraded to 64gb of faster ram than I had before for around $100. One of the best computer investments I have ever made.

3

u/Foreign-Discount-264 Dec 03 '25

Boy this comment didn’t age well. Happy you got it when you did!

1

u/Ellie-Biologist Jan 01 '26

rest in peace RAM prices

1

u/that_one_guy_upat4am Sep 14 '26

Just paid $280 for 16 😢

1

u/LifeHasLeft Dec 31 '23

The computers at my office all have nearly 100 GB of ram! They are beasts but they are being used for heavy computations

3

u/[deleted] Dec 31 '23

If theoretically we are able to achieve hard disk data read/write speeds comparable to RAM, would that eliminate the need of RAM itself?

The only advantage RAM offers is high speeds for data read and write. If a hypothetical memory device has the same speeds wont we just create a partition and run with it?

2

u/TheCloudfather Oct 05 '24

Yes, that would generally be correct. There are RAM Drives that allocate a certain amount of RAM to be used as a very high speed storage drive, and there is Virtual Memory which allocates a certain amount of storage drive space to be used as additional RAM. The tradeoffs are pretty severe though, a RAM Drive is going to be very small in size (a couple of GB max) and virtual memory is going to be very slow.

There are more differences between a disk drive and RAM that are being glossed over though. RAM is connected directly to the CPU by a high speed bus, so the CPU can read and write directly to memory locations in the RAM. Disk drives are not directly connected to CPUs, they have a separate controller which is in between them and the cpu that coordinates communication and is a bottleneck as far as speed is concerned. So in a nutshell, if a theoretical high speed disk drive was available we wouldn't be able to use it like you are describing, a whole new computer architecture would need to be designed for it.

1

u/[deleted] Oct 05 '24

I understand we have to revamp the whole heirarchial structure we have with CPU registers > RAM > Hard drive. This hypothetical storage would greatly simplify the bus and general cpu architecture right? will there be any significant improvement out of this?

1

u/P-Jean Dec 31 '23

That’s a really good question. That’s a bit beyond my understanding, but I know that you can use your HDD as RAM in the form of virtual memory. I think it’s limited by the bus speed to the drive. I’ve wondered why SSDs aren’t used in this way. A partition, like you said, would make sense if the speed is comparable to stuff like RAM and cache.

Maybe someone here who deals more with hardware can chime in. I only know the basics of memory management from a software perspective, and even then, there’s always exceptions.

2

u/[deleted] Jan 01 '24

Yeah I was actually thinking of VRAM, only with entire RAM in memory.

Maybe the very frequent read/writes in SSD would potentially decrease the lfiespan and won't be that fast?

1

u/P-Jean Jan 01 '24

It would decrease the lifespan of a platter RAID drive for sure.

2

u/purepersistence Dec 31 '23

RAM is volatile memory

The most common type of RAM is dynamic and therefore volatile like you say. Static RAM is not volatile. It keeps its content after power-down/restart. Dynamic RAM is slow and cheap and the most common form. Static RAM is fast and expensive. Dynamic RAM is based on capacitors, which loose their charge over time and hence the need to keep refreshing the memory by recharging the capacitor. Static RAM is based on flip-flops which retain their state after powered down.