Eli5: Why don’t computer games use all available RAM?

364 views

For example, there’s a racing game I play that is a 20GB total install and I have 32GB RAM. The game never uses more than 5GB RAM.

Why does it unload and reload between races? Wouldn’t it make sense to keep everything in RAM after it’s loaded it once?

In: 0

6 Answers

Anonymous 0 Comments

It delegates that to the OS. A program has to work on the assumption that it is not the only thing running on the computer, and it cannot hog all memory. If it wanted to use all the RAM for caching, it would need to coordinate with the OS to gracefully release some of the memory back when something else needs it. But the OS itself also does file caching in unused regions of the RAM! So the program can just unload the asset, and assuming it’s not expensive to unpack it from the file format, it can just load it again and count on the OS to give it the memory cached file if it hasn’t been evicted from the OS cache yet. So, there is cache, it’s just counted for the OS cache in task manager, not the program.

Then there is Cities Skylines which gives nary a fuck and just allocates 40 gigabytes to load a few dozen building models.

You are viewing 1 out of 6 answers, click here to view all answers.