10

Opening 20+ tabs in Firefox inevitably leads to a situation where 2-3 tabs are constantly using a fair amount of CPU, slowing the entire system down. I wonder if it's possible to impose a limit on total CPU time consumed by each tab. I understand it may not be possible to find out how much of that time is consumed by plugins and the like, so I'm OK with limiting only Javascript execution time.

There is this addon called suspend tab which takes the right action but based on a wrong criteria, stopping (and unloading) all inactive tabs after a timeout. However, this feels like carpet bombing: I have tabs with books or articles I'm reading, and most of them are not offensive. I'd rather not have to reload them unnecessarily, as they are often quite big and take time to load.

Note this is different from a popular question about identifying offending tabs. I'm not interested in hunting such tabs manually.

I use Firefox and have no immediate intention to go for a different one. However, I welcome relevant answers for other browsers, because having a browser which goes easy on the CPU may convince me to switch.

4
  • 1
    The biggest problem with many tabs open is that you eventually run into a resource question. Firefox takes more CPU usage whereas Chrome does not. But Chrome on the other hand uses more memory so you basically get into the same problem. In fact this is something that will come back to any browser. That said, it is possible to pause an actual process. Process Hacker can do this amonst others. If your browser creates multiple processes (one for each tab) you can pause its entire process. The tab will become unresponsive until you resume it. Can work with multiple instances of firefox too.
    – LPChip
    Feb 9 '17 at 19:32
  • @LPChip I know it should be possible to stop/resume a process (which is arguably not very convenient and user-friendly), but I also believe it should be possible to stop javascript processing in a tab. Personally, I have never run into memory issues, only constant CPU load issues. Perhaps that's because I have more RAM gigabytes than CPU cores :) Feb 9 '17 at 20:16
  • I have 16 gigs of ram myself and still many tabs on chrome slows down my system due to massive ram usage.
    – LPChip
    Feb 9 '17 at 20:27
  • I wish there was something that could be done from inside Firefox itself. For now I've written a (Windows Java) program that will limit Firefox to a percentage of a single core CPU usage when it has been in the background for a certain amount of time. As soon as the window gets focus or the mouse hovers over it, the time out resets and it gets full resources again -- it's pretty ridiculous Javascript can just hijack a ton of resources for who knows what.
    – john16384
    Jan 30 at 17:50
1

You can use the command line utility cpulimit (install by aptitude install cpulimit or brew install cpulimit for OSX) by limiting the maximum CPU usage per tab. Typing about:processes in Firefox will give you the process ids. Assume the offending tab has process id 1234. Then

cpulimit -l 10 -p 1234

would limit that tab to 10% CPU usage.

An alternative would be to start another instance of Firefox or Firefox Developer Edition, put all resource-intensive tabs there and limit the entire application with cpulimit.

0

You can use the utilities "nice" and "renice" to set/change the priority of processes so they take up more or less CPU time.

For example this command would set the process with the process ID of 987 to have a priority of 1:

renice 1 -p 987

And this would set the process with the process ID of 987 to have a priority of 19:

renice 19 -p 987

Processes with lower priority values are given more CPU time and processes with higher priority values are given less. Typically priority values range from -20 to 20 and default to a value of 0 if not otherwise specified.

3
  • find PIDs related to FF; $ ps -ax | grep -v grep | grep -E 'COMMAND|firefox'
    – Hannu
    Jan 1 at 10:15
  • I'm sorry, but renicing Firefox will not actually help much. The CPU will still be busy (and the fan will keep blowing at max speed), and opening new tabs will be just as slow because new tabs will have to share the CPU time with the problematic tabs. I actually keep using "Suspend Tab": sure, reloading tabs takes some time, but at least after 10 minutes the CPU consumption goes to zero no matter what tabs I have open. Jan 19 at 13:22
  • Oh. What is renice for if it doesn't limit CPU usage? Jan 22 at 2:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.