I am on Sierra 10.12.6 (Mac Pro, mid-2012), and learned that the previously available web server included with OS X was no longer available with 'non server' versions. Then I can't recall where heard/read that it was again available with High Sierra. The limits set via ulimit only affects processes created by the current shell session. The 'soft limit' is the actual limit that is used. It could be set, as far as it's not greater than the 'hard limit'. The 'hard limit' could also be set, but only to a value less than the current one, and only to a value not less than the 'soft limit'.
OS Platform: macOS 10.15 Catalina or later With Screen Time on Mac, you can set limits on your computer as easily as you can on an iPhone or iPad. It lets you block porn on Mac by limiting the use of apps, websites, or only allowing certain websites.
Click here to return to the 'Limit CPU usage for an application/process' hint |
cpulimit has been ported to OSX in the subversion repository. Ironically, the checkout I just compiled form from there used all extra CPU time to run cpulimit. (any coders want to make a patch?)
While this script is a bit of a hack, I'm keeping it around, since I've got a similar use, and I get tired of hearing the cooling fans on my MBP when I'm in no hurry, and this is working more or less as described.
Stupid question, isn't this thermal cycling (at the processor level) also not that great for durability? (The fans are certainly been spared by this method.)
The script can be very much simplified (variable i is not needed):
while true
do
kill -SIGSTOP $pid
sleep $sleeptime
kill -SIGCONT $pid
sleep $runtime
echo -n $dot
done
Have a look at cputhrottle (http://www.willnolan.com/cputhrottle/cputhrottle.html). It's made for Mac OS X.
Tested it with 10.6.6, works fine.
Bernhard
Thanks for this. I'll try it with Handbrake.
cputhrottle seems to be the better of the choices i've tried. Best free html editor for ipad. It doesn't seem to work as smoothly as cpulimit does on linux, but it's certainly a workable solution. I used it all the time.
Basically, this is turning the process on and off according to a defined interval. Definitely ugly, but I can't think of a better way to accomplish your task except perhaps running the process in a VM or binding it to a single core. https://ta-software.mystrikingly.com/blog/battles-of-napoleon-mac-os.
How can I bind or limit an application to use a single core?
You are both right and wrong. I just had Handbrake crash on me using this script, which could be an example of the pitfalls of this method.
However, your method, ie, nice, does nothing to keep the total CPU load below 100% (per core), in fact this has already been said in the article, nice is not a solution to reduce the total CPU load.
What might work more elegantly is to simply disable one CPU core via the Developer Tools. I do not know how much this reduces the thermal load but is bound to reduce it somewhat (unless the TurboBoost kicks and completely overcompensates for this, but then you might be able to disable the TurboBoost via the developer tools as well, you might even be able to limit the CPU speed itself, I do not know.
I tried cpulimit, checked it out and compiled it with make and ran it with: cpulimit$ ./cpulimit -l 80 -p 47879
Maybe I did not call it correctly but it did not work, ie, it did not limit my target thread to 80% CPU, cpulimit itself consumed a sizeable chunk of CPU cycles itself and something sucked up my 8 GB of memory. I did not realize this after I had quit my target thread and cpulimit itself, so I am not sure which process gobbled up all my memory, either cpulimit itself or maybe my target thread.
Thanks for this. I'll try it with Handbrake.
cputhrottle seems to be the better of the choices i've tried. Best free html editor for ipad. It doesn't seem to work as smoothly as cpulimit does on linux, but it's certainly a workable solution. I used it all the time.
Basically, this is turning the process on and off according to a defined interval. Definitely ugly, but I can't think of a better way to accomplish your task except perhaps running the process in a VM or binding it to a single core. https://ta-software.mystrikingly.com/blog/battles-of-napoleon-mac-os.
How can I bind or limit an application to use a single core?
You are both right and wrong. I just had Handbrake crash on me using this script, which could be an example of the pitfalls of this method.
However, your method, ie, nice, does nothing to keep the total CPU load below 100% (per core), in fact this has already been said in the article, nice is not a solution to reduce the total CPU load.
What might work more elegantly is to simply disable one CPU core via the Developer Tools. I do not know how much this reduces the thermal load but is bound to reduce it somewhat (unless the TurboBoost kicks and completely overcompensates for this, but then you might be able to disable the TurboBoost via the developer tools as well, you might even be able to limit the CPU speed itself, I do not know.
I tried cpulimit, checked it out and compiled it with make and ran it with: cpulimit$ ./cpulimit -l 80 -p 47879
Maybe I did not call it correctly but it did not work, ie, it did not limit my target thread to 80% CPU, cpulimit itself consumed a sizeable chunk of CPU cycles itself and something sucked up my 8 GB of memory. I did not realize this after I had quit my target thread and cpulimit itself, so I am not sure which process gobbled up all my memory, either cpulimit itself or maybe my target thread.
How to safely remove flash drive from mac. Negative numbers in nice actually allow MORE cpu usage. Positive numbers cut priority down.
Limiter Mac Os Sierra
You're not quite right there.. first off, it's SIGSTOP and SIGCONT, not SIGSTART, but I'll assume that's a typo. SIGSTOP isn't what is sent by the terminal when you press control-Z; that's SIGTSTP, which stands for 'Tty SToP'; the signals are different because SIGSTOP cannot be trapped by the program you are controlling.
Your point about this interfering with the operation of some programs is, however, quite valid.
(Amusingly, Wikipedia has an article for each POSIX signal, including http://en.wikipedia.org/wiki/SIGTSTP )
A paid alternative is Coolbook.
It offers cpu undervolting as well as fine control over cpu speed steps, cpu throttling and temp limits.
Limiter Mac Os Download
'Though Fan Control can help keep a MacBook Pro cooler, ultimately things that hammer both CPUs can get things so hot that even the fans won't keep the temperature down — and high heat will shorten the lifetime.
Limiter Mac Os Catalina
There's another trick that I use — just pop out the battery and the CPUs will be limited to 1 GHz (at least this is the case with my MBP Dual 2.33 GHz machine). While you obviously need to keep the unit plugged in (and mine's normally also on a UPS circuit when I do this), it's about impossible to get the unit too hot when it's limited to 1 GHz. https://epifree.mystrikingly.com/blog/adobe-reader-download-vista. Great for those multi-hour processing jobs.