
How I doubled the battery life on my Mac by closing one tab in Chrome - primozcigler
https://medium.com/@primozcigler/how-i-doubled-the-battery-life-on-my-mac-by-literally-closing-one-tab-in-a-browser-d96f2c5374db#.3fbamwstb
======
vardump
I often do this with OS X Chrome:

    
    
      killall -9 -m "Chrome Helper"
    

It kills all Chrome tab renderers, but you can easily reload them where you
left off. Ultimate battery saver.

Chrome seems to even remember textarea / input contents.

Edit: Not that I've ever had any issues with that simple killall, however the
following might be safer, it tries to match the process path, name and
"\--renderer" command line parameter:

    
    
      pkill -9 -f "Google Chrome\.app/.*/MacOS/Google Chrome Helper .*--type=renderer"

~~~
SeanDav
Is there a Windows equivalent process?

~~~
vardump
Well, this is a bit hackish, but I got this to work with a minute of effort:

wmic Path win32_process Where "CommandLine Like '%chrome.exe\"
\--type=renderer%'" Call Terminate

Tried it on Windows 10, latest Chrome. Ctrl-r didn't work on those killed
tabs, had to click reload button. But other than that, the effect seemed to be
same than on OS X.

Use at your own risk.

You can't use taskkill, because on Windows, all Chrome processes have the same
file name, chrome.exe.

Edit:

This one should be a bit more reliable and safer. Note that it is not
completely visible because of HN CSS:

    
    
      wmic Path win32_process Where "CommandLine Like '%--type=renderer%' and Name='chrome.exe'" Call Terminate

------
zimpenfish
I am quite happy with The Great Suspender for automatically suspending tabs -
has a good range of options for tweaking.

[https://chrome.google.com/webstore/detail/the-great-
suspende...](https://chrome.google.com/webstore/detail/the-great-
suspender/klbibkeccnjlkjkiokjodocebajanakg?hl=en)

~~~
srgseg
The OneTab extension can also be used to convert all your hoarded tabs into a
list, saving you memory and CPU.

[https://chrome.google.com/webstore/detail/onetab/chphlpgkkbo...](https://chrome.google.com/webstore/detail/onetab/chphlpgkkbolifaimnlloiipkdnihall)

------
mikeash
Maximum battery life depends on the CPU being idle most of the time. Running
an app that constantly uses the CPU will greatly shorten battery life. A web
page constantly running code will make the browser constantly use the CPU.

So... great? All true, but why is this on HN? This is the sort of tip which
belongs in a "...For Dummies" book.

~~~
Aeolun
I think it is more that this particular tab was somehow responsible for eating
half of his battery life. It's not particularly clear that that particular
page would consume an an insane amount of CPU/Battery.

~~~
mikeash
I'd hope it would be quite clear to this audience. Intensive tasks can eat far
_more_ than half your battery life. My MacBook Pro goes from 8+ hours of
battery life to less than 2 if I run certain (not particularly fancy-looking)
games, for example. The difference between idle consumption and maximum
consumption is gigantic, which in turn implies that your battery life can be
massively impacted by consistently going beyond idle.

Again, all true, but I don't understand why it's here.

~~~
primozcigler
Yes. But sometimes you will open up a website in a new tab. It won't be
happening nothing special there, as least not visually. So you will assume it
doesn't hurt performance/battery of your laptop.

But if the developer of that site left somewhere in JS something like
while(true) {...} that page will drain your battery, even if you're not
looking at that specific tab. And even if you are in other app than Chrome.

~~~
mikeash
Again, true. But why is that worth posting here? This is Computer Use 101
material. That doesn't mean it's not valuable to some people, but for this
particular audience it's about as obvious as "water your plants if you want
them to grow" would be on Farmer News.

~~~
heinrich5991
I haven't connected battery life to opened tabs before. There, this link was
worth something to me.

------
S_A_P
To add to the TLDR, its not Chrome's fault, but rather, a badly coded page
that is using too much CPU.

~~~
Houshalter
I would say it is somewhat Chrome's fault, since tabs in the background should
use less CPU. They also don't give users any control over resource usage, or
notify them which tabs are using resources (except in that task manager thing
which is hidden away, and not very reliable in my experience.)

Actually Chrome does slow down tabs in the background. On my computer whenever
I put a CPU heavy tab in the background, it crawls to a snail's pace. And if
you don't touch it in a long time, it is suspended and saved to the hard
drive.

Which is why this story is weird. This shouldn't even be an issue.

~~~
Mithaldu
> tabs in the background should use less CPU

That is a naive view on it. Javascript can be doing a LOT of things. It could
be rotating a product carousel; or it could be running a browser game. In both
cases that's something that can use a LOT of CPU, but in the latter case the
user might want it to continue processing in the background. How is the
browser supposed to differentiate this on its own?

~~~
tluyben2
But why can you not choose to either keep tabs you are not currently in focus
with (so you are looking at another tab than the 50 others you have open)
fully running, running at some max % or freeze completely? The latter just
freezing the process which will require unfreeze but as it is a user choice it
depends on their browser behavior.

~~~
Mithaldu
I was commenting on doing such automatically. (Hard to implement.)

Doing it manually would be great, but then you run into Chrome's obsession
with remaining simple and "slim", regardless of whether this happens to the
detriment of users.

------
agentgt
The article is pretty simple and not even really helpful for technical folks
(since I'm sure most on HN are aware of the chrome task manager)

It does remind me of the serious issue with horrible Ad heavy sites and opens
broader questions like are there other plugins/apps to ban cpu intensive
sites? Even google getting involved with a ranking of how cpu intensive a site
is might be interesting. In fact I was expecting the article to go down that
path and was rather disappointed it was so simple.

I recently had to disable javascript on Wikia because the site had useful
information but the Ad javascript code was horrific performance wise.

------
jjp
TLDR - shutdown tabs in Chrome that are consuming CPU. Write-up explains how
to use Activity Monitor to diagnose and identify tabs causing problem.

------
greggman
On my dual GPU MBP the biggest thing I do to get battery is use gfxCardStatus
to force the MBP to use the integrated GPU only. Of course I do graphics and
game related stuff but for example having Unity3D open but idle will keep the
MBP in discrete GPU mode using lots more energy. Similarly having a google
maps tab open in Chrome will also put the GPU in discrete GPU mode.
gfxCardStatus lets me force it to integrated only when I don't need the speed.

Another minor thing I do is if I'm working on a game/visualization, at least
in debug mode I make then pause if not the focus. Otherwise as I flip between
my editor and my app/page the app/page is eating battery as it continously
renders

------
discardorama
AKA, ".... with one simple trick!"

I wish Firefox had an ability to see which tab was hogging resources.

~~~
jimmaswell
There's an experimental offshoot somewhere with per-tab processes or threads,
does that one do that?

------
lsiunsuex
Interestingly enough - when I opened the Task Manager of Chrome, it was this
article that was consuming the most memory / cpu of my open tabs.

------
chinathrow
Maybe the linked page is not badly coded at all - maybe that is done on
purpose. Has anyone debugged why the mentioned page [1] is consuming so much
CPU time?

[1]

[http://www.xe.com/currencycharts/?from=EUR&to=USD&view=1M](http://www.xe.com/currencycharts/?from=EUR&to=USD&view=1M)

~~~
rtkwe
It wasn't for me. I've let it sit for a couple minutes too. I can get it up to
about 20% if I'm sitting there mousing over the chart with 2 years of data but
other wise it doesn't seem to do too much.

I've noticed some site's scripts really don't like coming back from a long
sleep so maybe it was some edge case like that causing it to eat so much CPU.

~~~
godshatter
When running Chrome, the CPU goes into the 15% to 20% range when running the
mouse in circles over the chart on my Windows 7 box at work. When running Pale
Moon, I get about 10% to 15%, even after allowing all javascript domains in
NoScript. Of course, I'm still running an ad blocker and don't see the top and
right-hand column ads which makes me wonder if the author happened to catch an
ad that was coded badly.

~~~
rtkwe
That's pretty much my setup but with Windows 10 and uBlock and matches what I
saw.

------
mcv
I also use Chrome's Task Manager a lot to figure out why my laptop's fan is
suddenly trying to take off. Lately, though, the worst culprits seem to have
been eliminated, and Chrome runs reasonably well even with the insane number
of tabs I still have open.

Today it is Node that's draining my battery.

------
justinsb
I do spend too much of my day with Activity Monitor open (though I am a
tabuser that is seemingly incapable of closing tabs). I hope we'll see smarter
behavior from browsers with throttling or paging out of least-recently-used
tabs; this isn't something people should have to do.

------
agumonkey
Anyone had the same CPU usage on the currency page ? it stays at 9% on my old
machine.

ps: also check extensions, a few can leak GB of memory.

------
jkot
My CPU spins at 60% almost constantly due to type of work I do. I quadrupled
my battery life by swapping batteries.

------
brudgers
Not really Mac specific since it's a feature of Chromium and by inheritance
Chrome.

~~~
primozcigler
Agreed. It will work in win/linux as well, as the Chrome Task manager is
available everywhere you can install Chrome.

------
sandGorgon
Anybody know if powertop can give this data on Linux?

~~~
creshal
Yes.

------
paride5745
TIL if I close an app, my battery last longer.

Seriously, you should always close what you do not need. It is not only for
energy efficiency, but for security as well.

~~~
ska
TYMHLSIFARTA (Today you might have learned something if you actually read the
article).

It's not a great write-up, but it isn't about closing an app.

It is about the potentially surprising impact of individual tabs that keep
code running, and a way to identify them.

