why does a program/game slow down or cap out on resource allocation well before the computer is out of resources?

197 views

why does a program/game slow down or cap out on resource allocation well before the computer is out of resources?

In: 0

3 Answers

Anonymous 0 Comments

Many programs, games especially, are largely sequential. Each step depends on the step before it. So they have to be done in a specific order.

Basically all modern CPUs are multi-core CPUs. Each core is the thing that does the actual processing. So a 4-core CPU can do 4 things at once. But sequential stuff has to be done on a single core. Doing multiple steps at once might mess up the order. So one core is doing all the work, while the other cores are mostly just sitting around (or doing something unrelated).

Other parts of the computer mainly exist to support all the CPU cores, so if most cores aren’t doing much then the other resources aren’t doing much either.

Anonymous 0 Comments

There are a couple possible reasons, which basically break down into “Because the OS wants to keep some resources in reserve” and “Because the program is hitting a roadblock somewhere else”.

1. The computer is limiting the program from consuming too many resources, so it doesn’t eat resources that other programs need, including potentially the operating system. This stops rogue code in, say, Spotify, from crashing your computer or causing you to get frustrated at other programs responding slowly. This may sound silly, but keep in mind that if a game were to take all the resources, you wouldn’t be able to alt-tab or close the game or run a VOIP program in the background.

2. The program needs a lot of one resource, but not very much of another. A game might need 8GB of memory and 50% of your CPU capacity, but 100% of your GPU capacity. You might only have 7 GB of memory available, so it’ll run at 80% GPU capacity because it’s not actually waiting on the GPU, it’s just trying to get things in and out of memory. This may occur at a granular level you can’t see very well; maybe your CPU has 16 cores but a game can only use 2. That’s 1/8th total CPU utilization, but the game is using 100% of what it can.

Fun fact: If you go to task manager on any windows version, and go to details (or to the processes tab on older versions), and right click on a process, you can manually set the priority of the program to higher or lower. In the olden times (like 15 years ago), if a game was running badly, you’d go in there and set it to realtime so that it would prioritize the game over anything else.

Anonymous 0 Comments

That depends on the kind of resources you’re talking about. I’m guessing you’re thinking of apps running out of memory. That happens because the OS tries to be clever.

If there’s not enough RAM for all the memory needed by all the running applications then some of the memory gets dumped out to the pagefile on the disk. This frees up RAM for apps which need it more urgently, but it’s a fairly slow process. So if your game asks for a bunch of memory and the OS decides it needs to evict some *other* data to free up RAM for you, your game will slow down while that is being done.

This is also a warning flag that we might run out of memory soonish, so it might precede the game aborting completely, as you’ve seen.

Ideally, the OS picks data to evict which hasn’t been used in a long time, but of course the more memory your game asks for, the more aggressive the OS has to be in finding stuff to kick out. Eventually the OS might start dumping data that your game needed quite recently (and will need soon again), which becomes a vicious cycle where the data you need is constantly being swapped in and out of memory, slowing everything to a grind.