eli5: Why do programs freeze, even though CPU, GPU and RAM usage are under 70%?

256 views

[ad_1]

eli5: Why do programs freeze, even though CPU, GPU and RAM usage are under 70%?

In: Technology
[ad_2]

That’s not everything that can cause a bottleneck.

The program is waiting on something, this could also be your hard drive or internet connection, actually program freezes most often happen because of this when the program is not properly coded.

This can happen when there is a deadlock. There are many different ways this can happen but in general the process stops executing because it is waiting for a condition which will never happen. One such example is if two execution threads are both going to make changes to an object and needs exclusive access to that object. If they both run at the same time they might end up stepping over each other and corrupting the data. But if these two jobs are started very close together then the first thread might see that the second one have started and therefore will wait until that is done, but the second thread is also seeing that the first one have started and therefore will also wait until the other thread is done. There fore you end up with two threads both waiting for each other and none of them will use any CPU. There are also plenty of other examples of other deadlock situations.

Most applications run in a loop: They receive events (move movement, button presses, minimize, exit, etc), do something based on those events, and then listen for events again. When a program freezes it’s usually because the code in an event handler has stalled. The program is stuck, it cannot loop back and process more events and becomes unresponsive. It might be stuck in an infinite loop, or waiting for a resource like a file, or any number of things causing the program to wait.