Fix lagging programs on Windows

Now and then programs (especially games) are putting all their load onto the first core of the CPU, creating performance issues. To combat this, the CPU affinities of a program can be changed avoiding the use of that specific CPU core. This can lead to the program evenly distributing the workload onto the other cores, which then can increase the overall performance or remove any lags.

This is definetly not a daily solution and should be applied carefully. Changing CPU affinities can affect the performance and stability in a negative manner if not done carefully.

Identify CPU core with Resource Manager

Even though most of the times it is the first core, it is better to identify the CPU core to avoid any fatal errors. For this, open the Task Manager (e.g. by pressing ctrl + shift + esc) and navigate to the tab "Performance". To open the Resource Manager, click onto "Open Resouce Manager" on the bottom of the window.

In the Resource Manager, find the program in the list of processes and tick the box on its left. Watch the graphs on the right to see which CPU cores are used by the process. Should a graph show that a CPU core is running at its max, while other cores are barly affected, indicated that the load is not properly balanced across the CPU cores and possibly creating performance issues.

To test if this is the case:
Enter the Task Manager and navigate to the tab "Details". Find the program in the list and right click on it. From the menu select "Set Affinity". Find the CPU core that has been identified before and remove the tick of the box. This will prevent the program from accessing that CPU core. Go back to the program and see if the performance issue has been resolved. If yes, continue with the next step to permanently fix this issue.

Calcualte the Values for the Cores

To simplify the process, you can also use CPU LagStop to calculate and get the script written.

The calculated value will be used for the next step to determine with CPU cores are supposed to be used.

To define the cores, simply combine the numbers of the cores. Remember that the counting starts at 0. The first core is core 0.

Core 0 = 0000 0001 = 1
Core 1 = 0000 0010 = 2
Core 2 = 0000 0100 = 4
Core 3 = 0000 1000 = 8
Core 4 = 0001 0000 = 16
Core 5 = 0010 0000 = 32
Core 6 = 0100 0000 = 64
Core 7 = 1000 0000 = 128

For example:
Cores 0 to 3 -> 1 + 2 + 4 + 8 = 15
Cores 4 to 7 -> 16 + 32 + 64 + 128 = 240

Cores 1 to 7 -> 2 + 4 + 8 + 16 + 32 + 64 + 128 = 254
Cores 2 to 5 -> 4 + 8 + 16 = 28

Fix it with a Script

First, create a shortcut to the application and place it e.g. in the folder of the program (or somewhere you can find it easily).
After this, open a text editor and create a .bat script. Name it however you like.

The script is structured as following:

@echo off
title title-name
start "shortcut" "C:\Path\To\Game\Shortcut.lnk"
timeout /t 20 /nobreak
PowerShell "Get-Process process-name | Select-Object ProcessorAffinity"
PowerShell "$Process = Get-Process process-name; $Process.ProcessorAffinity= core-number"

Save the script and run it to open the program with it only using the previously specified cores.

Here is an example using Lego Star Wars (the 2005 classic), which is supposed to run without using the first core. Keep in mind that the filepath might need to be adjusted.
@echo off
title Lego Star Wars
start "LSW" "C:\Games\Lego Star Wars\LSW.lnk"
timeout /t 20 /nobreak
PowerShell "Get-Process LegoStarWars | Select-Object ProcessorAffinity"
PowerShell "$Process = Get-Process LegoStarWars; $Process.ProcessorAffinity= 254"

Have fun!

Execute the script and enjoy a lag-free program.

Go Back