Three months down the drain« an older post
a newer one »Happy 3 years!

Mystery number four, solved.


Over the last two years, I've developed a series of tricks, rituals and processes that maximize the battery on my laptop. The current laptop, being all shiny and new and cool and number three in the last four years, is a MacBook Pro, thanks to Kate and Mike and their Apple-y ways (just close enough to Linux that I really like it, but all pretty and bee-you-tee-full, blah blah blah).

The MBP, named fuji, has a battery life of around 3 hours, 4 if I'm not running many other programs than a text editor (which happens rarely, because I need the webserver and database server going to check the website I'm usually developing, and the browser to actually view said website).

The previous laptop was an iBook, recently renamed gala (see the theme?) when the name fuji went to the new shiny MBP), and that thing could last for-ev-ver. When I first started using it, I could work comfortably for six hours on one charge, longer if I turned off what I didn't use.

The long charge required several adjustments: no videos, no iTunes, turn off the wireless (recall, I'm developing locally, so this is fine), turn down the screen. I considered all of these steps incidental to the fun of being able to program across the country, non-stop.

Towards the end of my daily use of the iBook, however, the charges stopped lasting as long. Instead of my expected six, four if I was rough, hours of battery, I started getting two hours, then one hour, then half an hour. As the length of the charge dropped, I started turning off applications, watching the Activity Monitor output to see what was causing the drain.

Eventually, I tracked the problem down to Firefox.


I use the new tab feature very heavily in Firefox. I rarely close the tabs, they just accumulate until I realize, whoops, I have eighty tabs open on four lines and they're taking up real estate on my browser. Then I'll bookmark and close the tabs. What I really want is a plugin to save pages, like does, but to my Drupal website. This will go nicely with my mirror module (that's still not done - grrrrr....). Until then, I'll tab-bookmark-tab away!

When the iBook started losing charge quickly, and Firefox seemed to be culprit, I assumed the problem was the kabillion tabs I use. If I needed to be low-energy-consumptive, I'd dim the monitor, turn off the wireless, close Firefox, and use Mozilla or Safari to test pages. Easy enough.

So, imagine my shock when, just today, I open up my Firefox javascript editor and saw a new error popping up on the console more than once a second (but not quite twice a second). I looked at the error, realized it was for some annoying ad network, and immediately set out to find the tab that had the offending HTML in it.

I had to close 40 tabs before I figured that one out.

The problem was that I used FlashBlock and AdBlock to block flash and images from the offending ad network, but AdBlock didn't block the javascript coming from that ad network, also. As a result, the javascript loaded, and accessed the missing image and flash elements at a retardedly high rate, causing the javascript errors.

I believe this (general issue, not the specific page I was viewing before) was the cause of the high CPU usage from Firefox on the last box, and the cause of the fast battery usage rate.

Well, that and the ridiculously large number of tabs causing Firefox to hold a lot of content in memory.

Another aha moment, and yet another mystery solved.