What causes microfreezes in PC games and how can I minimize them?

If you've played rhythm games such as Audiosurf or Bit.Trip Beat you'll be familiar with this enraging phenomenon - the game just freezes for a few frames to a whole second, the game catches up with you frozen in place, and ka-boom. Your run is ruined and there's nothing you can do about it but start all over again.

What causes this? Is it CPU spikes from background processes that should know better? Is it sudden I/O requests spiking from the disk for no reason whatsoever? Is it the gremlins? I've even disabled live checking from the antivirus. No joy.

Is there something you can do to prevent this other than "close all background programs" like you're using DOS 6.0?


Solution 1:

Diagnosing these kind of things can be tricky, so be ready to invest some significant time to root-cause them. There are as many opinions about optimization as there are computers on the internet, so I'm going to do my best to hit the high points.

The first step is usually pinpointing why you're having issues. Are you having CPU, disk, or network spikes that correspond with your in-game latency? Using Process Explorer or Performance Monitor can help you track various trends going on in your machine (and can help you identify what is causing it to an extent):

Tracking CPU and Memory usage per process

Here's some more general advice. I don't know if all of this is going to apply to your specific situation, but it can't help to be more informed.

Clearly you want to minimize the number of processes running in the background while you game. Browsers, for instance, are generally refreshing and redrawing pages even if they're in the background. They're a key culprit in many cases. Flash animations on background pages eat your CPU without usually performing anything useful. If you don't want to shut down your browser completely, you might consider installing a flash or ad blocker, which at least cuts down on the useless churn the browser is doing.

Antivirus gets a bad rap, and there's a chance if you're playing a game that it is running in the background. I would suggest ditching the "name brands" in firewall/antivirus software (Symantec and McAfee) as they are known resource hogs. Microsoft Security Essentials is generally good enough for most people, it's free, and it tends to be lighter in terms of resource usage.

The flipside of antivirus software is that sometimes you can get infected with viruses and spyware that consume system resources without your knowledge. Make sure your antivirus is up to date and running, and that you've scanned for spyware recently with a program like Malwarebytes or Spybot S&D.

Many software packages install background tasks that run constantly as well. If you don't need this functionality, it's good to turn it off. Video drivers and printer drivers are surprisingly some of the worst. You can use MSConfig to examine the background processes that start with Windows, and decide if they're worth keeping. Most of the time your drivers will work just as well without the constant background task running, but make sure you test thoroughly to make sure there aren't any issues.

Windows Update is another background process that runs frequently and can consume CPU and network bandwidth if you let it. As long as you monitor it closely, it should be safe to set it to a more manual mode so that Windows doesn't choose the best time to download and apply patches for you.

Windows Services provide useful functionality to your computer, but not all of them are required. There are guides on the web about what services provide what features, so you can decide if you want to selectively disable them, and perhaps regain some lost resources.

Sometimes bad drivers (outdated or just buggy) can cause issues in games. Try looking for the most updated drivers you can find.

Solution 2:

Often times, large hitches can be caused by major paging issues. Most games (especially cross-platforms ones that have to deal with slow optical discs) have smart I/O managers that handle I/O asynchronously, either on a separate thread or using an asynchronous API, such that the game can continue to render and update while I/O is occurring.

One type of I/O that they cannot control, however, is virtual memory paging. If a computer is low on memory, it's quite likely that a large piece of a game's memory (textures, level data, code, etc.) will get paged out to disk, so that the next time the game accesses it (such as by, say, a piece of the game world coming into view), it gets paged back into memory by the OS. This paging is necessarily synchronous, so the game cannot continue to render and update while it happens, so big hitches in gameplay result.

If you have a lot of processes running on your computer and not a lot of memory, paging is quite likely a source of hitches. The easy solution is to upgrade your memory, if possible. agent6 also gives a lot of suggestions for getting rid of unnecessary background processes or reducing system load—these will also help reduce memory usage and reduce the frequency of paging.