I do this a lot:
- Notice my MacBook Air is running hot
- Open Activity Monitor, see "Google Chrome Helper" process pegged at 100% CPU
- Open Chrome's Task Manager to find the responsible tab
- Find and kill some blog post I opened two days ago whose JS is running an infinite loop
It's especially frustrating if it happens when I'm away from my desk, and my fans have been wearing themselves out all night for no reason.
How can I prevent this?
I know cputhrottle lets you cap the CPU usage of a particular PID, but Chrome uses many processes. I considered writing a script that periodically runs cputhrottle
on each PID in ps -A | grep Chrome
, but this would slow down foreground tabs as well, which I'd like to keep at full speed. Monitoring of foreground/background switches could be done through a Chrome extension, which would need to communicate to a daemon running outside Chrome via the Native Messaging API, but it seems like a lot of work both to write and to distribute. I'm hoping there's a simpler solution I'm overlooking.
Best Answer
UPDATE: In February 2021, this Chrome extension was removed from the Chrome Web Store because the new owner inserted malware and spyware. See this article on ZDNet for more details. You may want to try The Marvellous Suspender which claims to be a malware-free fork of The Great Suspender, but as with all downloads you should research and verify that it's safe!
Add the extension "The Great Suspender" to chrome. Once added, you are presented with the settings page, where you can choose when to suspend tabs, when to enable (for example, when in focus).
General settings view of Great Suspender:
I also check Automatically unsuspend when tab gains focus. When done with your desired settings, scroll to bottom, and click Save Settings.
I listen to music all day using Google Play, so I do not want that tab suspended, so I right-click on the tab, and choose Pin this tab.
Plugins themselves may be the culprit, so change when plugins run, settings -> advanced -> content settings -> plugins -> let me choose when to run plugin content