7

I'm looking for a way to limit the CPU usage by any application on Windows 7 to 50%. I've tried searching the Internet for a way to do this, and it looks like this is an easy thing to do on Linux and Mac OS X (one command in the terminal) but I'm not sure how to do it on Windows 7. Any help would be much appreciated. Thanks!

Rohan

Rohan
  • 383
  • 3
  • 6
  • 14
  • What about multi-core processors? 50% CPU usage would simply be limiting the process to use no more than half the cores. – Michael Myers May 05 '10 at 22:14

5 Answers5

6

You can use BES. It throttles CPU-hungry applications when asked. You can limit 3 programs maximum. I use this to run multiple online game clients and it works like a charm for me. You should run it with admin privilidges and in windows xp sp3 compatible mode. To adjust these settings, right click on the executable and chose options.

Here's the link for BES - CPU limiter.

4

If you are on a multi-core processor, you can right click the process in the task manager and set the affinity. This will define which cores are allowed to run the process. Uncheck half of the cores and the process will use 50%.

Or see this to do it programagically: Set affinity with start /AFFINITY command on Windows 7

Community
  • 1
  • 1
bradvido
  • 2,743
  • 7
  • 32
  • 49
3

You can limit the CPU usage of your process or any other process by adding the process of interest to a Job object, and placing limits on the Job object.

One of the resource limits which can be configured for Job objects is CPU usage:

If you have to use JOBOBJECT_BASIC_LIMIT_INFORMATION, pay careful attention to the note:

To register for notification when this limit is exceeded without terminating processes, use the SetInformationJobObject function with the JobObjectNotificationLimitInformation information class

And then use JOBOBJECT_END_OF_JOB_TIME_INFORMATION instead, since that's available pre-Windows 8.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
3

You can't limit the CPU usage of a process on Windows 7 or earlier as this resource is managed by the OS*.

However, you can specify to run a process with a certain priority, e.g. to run below normal priority. The various scheduling priorities can be set using the SetPriorityClass API function.

Scheduling Priorities

What you are probably trying to prevent is that your process affects the performance of the system in a way that the user would notice. In that case, setting appropriate priorities will be a solution. After all, you got an expensive CPU so why not use it whenever you can?

* See @Ben Voigt's answer for a possible solution on Windows 8 and above.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Dirk Vollmar
  • 172,527
  • 53
  • 255
  • 316
  • TL;DR version of this answer: "0xA3 doesn't know a way". Note that this isn't the same as there not *being* a way. – Ben Voigt May 03 '13 at 04:25
  • 1
    @Ben Voigt: Why so arrogant? Had a bad day? JOBOBJECT_CPU_RATE_CONTROL_INFORMATION is new in *Windows 8* (and Windows Server 2012) and the question refers to Windows 7. Unfortunately, I don't have the time to regularly check whether any of my old postings needs an update because there is a newer version of product xyz. – Dirk Vollmar May 03 '13 at 09:49
  • Thanks for pointing out that particular structure is new in Windows 8. I found the wrong one. The capability has existed for a long time, your answer is still (completely) incorrect. – Ben Voigt May 03 '13 at 14:16
  • @Ben Voigt: I see well how things like the total time or total user time of a process can be limited using the solution that you suggest. However, the question here is different and the documentation of the JOBOBJECT_BASIC_LIMIT_INFORMATION structure does not tell a way to realize a scenario where a process consumes only e.g. 50 % of the CPU within a time window. Hard quota management (http://technet.microsoft.com/en-us/library/ff384148%28WS.10%29.aspx), that works per-session, per-user or per-system is probably as far as you can get on Windows 7. – Dirk Vollmar May 03 '13 at 16:26
  • That documentation makes it clear that you can either set a hard limit (process is terminated) or receive a notification, which allows taking any of the actions that affect CPU usage -- you could do what Windows 8 now incorporates which is to suspend the process temporarily. Or you can tweak priority and affinity. Or a combination. – Ben Voigt May 03 '13 at 17:15
  • @Ben Voigt: Receiving a notification and taking action to affect CPU usage sounds reasonable. Yet again, this option is not available on Windows <8. – Dirk Vollmar May 03 '13 at 17:36
  • 0xA3: It is available since XP, or am I missing something in the JOBOBJECT_BASIC_LIMIT_INFORMATION documentation? – Ben Voigt May 03 '13 at 17:53
  • The documentation is terrible, but XP and later do allow you to get a notification. See [`JOBOBJECT_END_OF_JOB_TIME_INFORMATION`](http://msdn.microsoft.com/en-us/library/windows/desktop/ms684155.aspx) – Ben Voigt May 03 '13 at 17:56
0

You can use an excellent program called "process lasso".

In lasso you can, for example, limit some specific program to 1 CPU and low priority. Every copy of that program will run with these settings. I have used this program to manage CPU on terminal server and it worked very well!

Arsen7
  • 12,522
  • 2
  • 43
  • 60
wojtek
  • 19
  • 1
  • 1
    I guess you have been downvoted because of unreadable wording, and not because of the information quality. I hope my edit will help. ;-) And welcome to SO! – Arsen7 Sep 28 '11 at 07:36