AdBlock Plus Firefox Memory consumption

AdBlock Plus’s effect on Firefox’s memory usage

[Update: Wladimir Palant has posted a response on the AdBlock Plus blog. Also, a Chrome developer using the handle “Klathmon” has posted numerous good comments in the Reddit discussion of this post, explaining why ad-blockers are inherently CPU- and memory-intensive, and why integrating ad-blocking into a browser wouldn’t necessarily help.]

AdBlock Plus (ABP) is the most popular add-on for Firefox. AMO says that it has almost 19 million users, which is almost triple the number of the second most popular add-on. I have happily used it myself for years — whenever I use a browser that doesn’t have an ad blocker installed I’m always horrified by the number of ads there are on the web.

But we recently learned that ABP can greatly increase the amount of memory used by Firefox.

First, there’s a constant overhead just from enabling ABP of something like 60–70 MiB. (This is on 64-bit builds; on 32-bit builds the number is probably a bit smaller.) This appears to be mostly due to additional JavaScript memory usage, though there’s also some due to extra layout memory.

Second, there’s an overhead of about 4 MiB per iframe, which is mostly due to ABP injecting a giant stylesheet into every iframe. Many pages have multiple iframes, so this can add up quickly. For example, if I load TechCrunch and roll over the social buttons on every story (thus triggering the loading of lots of extra JS code), without ABP, Firefox uses about 194 MiB of physical memory. With ABP, that number more than doubles, to 417 MiB. This is despite the fact that ABP prevents some page elements (ads!) from being loaded.

An even more extreme example is this page, which contains over 400 iframes. Without ABP, Firefox uses about 370 MiB. With ABP, that number jumps to 1960 MiB. Unsurprisingly, the page also loads more slowly with ABP enabled.

So, it’s clear that ABP greatly increases Firefox’s memory usage. Now, this isn’t all bad. Many people (including me!) will be happy with this trade-off — they will gladly use extra memory in order to block ads. But if you’re using a low-end machine without much memory, you might have different priorities.

I hope that the ABP authors can work with us to reduce this overhead, though I’m not aware of any clear ideas on how to do so. In the meantime, it’s worth keeping these measurements in mind. In particular, if you hear people complaining about Firefox’s memory usage, one of the first questions to ask is whether they have ABP installed.

[A note about the comments: I have deleted 17 argumentative, repetitive, borderline-spam comments from a single commenter — after giving him a warning via email — and I will delete any further comments from him on this post. As a result, I also had to delete three replies to his comments from others, for which I apologize.]

85 replies on “AdBlock Plus’s effect on Firefox’s memory usage”

What is the purpose of the style sheet, and why is it injected into every iframe, and why is it so big? 🙂

and couldn’t FF share identical stylesheets (an optimization that probably won’t help much in normal websites)?


Indeed, FF could create a mechanism that would share identical stylesheets just for the addons, so they don’t bog the entire application.

Fx 31 includes support for CSS variables, so perhaps that can be leveraged into a solution.

If the problem is custom sort orders preventing deduplication, what would the performance impact be from using a list that isn’t reordered for each iframe.

Thanks for the link. There seems to be several ways of solving it, each with its trade-offs.

The purpose of that stylesheet is to hide things that cannot be blocked – a feature called element hiding. As far as Adblock Plus is concerned, only one stylesheet is created and registered globally. There is one rule for each element hiding filter meaning roughly 20 thousands right now if you are using EasyList. The fact that Firefox internally creates a separate (and not exactly small) stylesheet for each frame is something I only learned with

What about a feature to specify a list of domains to filter the element hiding rules? 99.99% of the element hiding rules are useless for me — I would much prefer to manually specify the sites I use frequently in exchange for reduced memory usage.

I have been doing this manually so far[0], but it would be so much easier if this were integrated into ABP itself.


> As far as Adblock Plus is concerned, only one stylesheet is created and registered globally

I am quite surprised at that statement. If I look at EasyList, it does appear that style directives are prefixed with a domain name. My assumption was that only the style directives for a specific domain are applied to that domain. If not, then my question is why not?

In easylist, there are quite a lot element hiding rule without specified domain provided. like ##div#ids which will be applied to all domains, hiding element <div id="ids"

Have you considered creating a stylesheet for each iframe which only contains what that iframe needs?

It might take more CPU, but by the looks of things it’s not actually fully shared anyway, and it would mean less processing by FF itself as it works through the consequences of thousands of rules that do nothing…

To give some alternatives to adblock:

I use only Ghostery on this computer, and it seems to block ads just as well. I think we already worked with them to reduce their memory usage, right?

With all Ghostery features enabled, I have some broken pages (for example, some pages directly call Google Analytics’ main object and this fails because the object is not loaded).

I also use Bluhell Firewall on another computer; this works nearly fine except some pages just stop loading sometimes. Reloading them make them work.

While it’s the first time I’m seeing this article, I can live with this (and I had this “Ghost-rank” option turned off).

It’s not unexpected that the Ghostry guys want to make money, and as long as it doesn’t hurt the users’ privacy, I think it’s actually quite smart to use users visits to collect which trackers are installed on which pages. The behavior can be altered by users (and I _think_ it’s opt-in but I don’t recall), it doesn’t include any user data when enabled according to their (repeated) declarations, it does have a lot of value for its clients, and users get a good product without needing to shell out money.

So far, IMO it’s a win-win situation. I’m guessing that if Ghostry will change their act to be less user friendly, it would create enough buzz to make most involved users aware of it, letting them to decide how to handle it.

But so far, so good IMO.

and this is exactly why you shouldn’t use Adblock Plus, which is basically an ad network in disguise. This isn’t about blocking ads but about filtering them. They just cashed in and got around $30 millions from players like Google and Amazon

The main problem with ABP’s the lists are just huge. You can get 99% of the benefit with just a handful of domain blocks.

It could also attempt to partition data more effectively. You don’t need that entire stylesheet for every webpage. And you don’t even need to have all the rules in memory; you could use a bloom filter for the domains + a cache that only holds the rules for accessed ones.

A handful of rules will catch the worst if it, but there’s a long tail that will drive up your total size if you try to get everything. My employer’s firewall blocks ABP from downloading easylist/etc, so I’ve been forced to create my own list from scratch. Currently it’s 182 domain filters, 723 EHH rules, and 66 exceptions. Although a number of the EHH rules are for non-ad related decrapification of various sites; but ad related rules are probably still the majority of entries there.

Not knowing who his employer is, there are employers who have security policies that involve on-the-spot termination if you plug a USB stick into any machine on the premises. So your idea, while very valid, may not be an option where he works.

Just email yourself the plain text list.

therefore clearly not an exploit to the corporate filters.

IE has a rather basic but built-in adblocker that monitor trackers around the web and block it automatically base on re-occurrence rate. It’s a heuristic approach that I think is much better for efficiency.

I hope ABP could do something like that instead of loading a 1+MB file of filter list.

To help with this, I build my own list from I filter element hiding rules based on the sites I frequently visit, so I end up with a very small stylesheet. All blocking rules are still present, but the memory use is still considerably lower than with stock EasyList+EasyPrivacy.

In addition, I also disable AdBlock on domains without ads (, for example).

Too bad these statistics are useless without telling us what the average memory usage of a page is *with* ads enabled. I dare to say that that could be even more than the 4mb per frame plus the constant 70mb…

Read the post again. You clearly weren’t paying attention the first time.

Every comparison was with and without ABP. For the TechCrunch comparison, I explicitly said “With ABP, that number more than doubles, to 417 MiB. This is despite the fact that ABP prevents some page elements (ads!) from being loaded.”

Question is : if the 400 iframes contain clumsy ads, will they use less than 2GB of memory ?

I know I wouldn’t use FF when there ABP wasn’t an option, so a big thank you to the ABP team! What if we turn the question around, how can Mozilla help ABP? Not a techie but could FF include a blocked domains feature ABP could tap into?

It’s not just about blocking ads, 50% of all reasons to use ABP is to kill all these overlays that cool webdesigners are bombarding me with (fixed headers and/or footers for example).

50% seems like it might be a little high, at least for most people. For myself, I’ve never used ABP for killing overlays – I just use Chrome Inspector and delete the elements.

Suggestion: Let me automatically disable all rules with less than X hits after a few weeks. This should greatly reduce the number of rules that are useless for the sites I regularly visit. If the filtering results are getting worse over time, I can enable all rules again for a few weeks.

Good idea. But if I’m not mistaken, you can still count matches without applying them afterwards? Therefore ABP could learn and adapt without manual intervention.

ABP’s filter preferences does show the number of hits each rule has. YOu can sort by that to find the un/minimally used rules/items. From there you can do a mass select and use the space bar to clear all the rules you want to get rid of.

Assuming rules turned off this way don’t contribute to the filter list this should help a lot.

Te same behaviour exists in chrome as well. Got the website you linked to over 2.4GB in Ram usage.

One of the best tricks ive learned to help block ads when ABP isnt available is to load up the Windows host file with redirects for known ad servers. The file size is currently (2014) around 500kb, but usually does pretty well. There are also instructions on how to set it up. It is also just a text file no binaries or exe to run.

I’ve never been fond of the idea of having a giant hosts file. While I haven’t tested, I fear it’d impact performance to have thousands of entries to look through for every domain lookup.

Hopefully I’m wrong and OSes are smart enough to preload the hosts file into some type of tree structure for fast lookups.

The impact is actually a lot less than you’d think, although you’re right, it can be significant – the hosts file is checked for every single DNS resolution.

Giant host file is inefficient.
Years ago, I looked at the machine of someone in the family, where, unlike me, there was no cookie whitelisting.
I was shocked at just how many cookies where in the cookie jar.
I sorted them by domain w/ awk | sort | uniq -c | sort -n then took the offenders w/ the highest cookie counts and did something like:

In djbdns.

The advantage this has over host file is the wildcarding, and of course that it works for all machines on the domain.
Did this years ago, and haven’t noticed any significant impact, apart from those times I actually try to click on a google ad and google sees fit to send it through doubleclick. I just type in the name of the company myself instead.

There are a number of DNS cachers out there to improve performance. Ubuntu even uses one by default, where you can add new rules to the default config. You can even change it to bind to the external interface and point other machines in your home at it fairly trivially.

So instead of ABP someone could create a mildly altered set of ad domain cookies and it would do the same thing without the performance hit of ABP or Hosts files? So why isn’t someone making an add-on like this already?

Oh, I see; you’re altering DNS entries. On Ubuntu. It’s an interesting thought though, to think how to get away from Adblock altogether (which actually reminds me I read somewhere once that it’s not that hard to configure your own router to block ads).

It slows. Your entire. Computer. Down. Not just Firefox (that, too) or whatever your browser of choice is. Tried it so many times and given up so many times. Most recently I didn’t realize I was using jv16 PT to create an adblocking Hosts file – until my computer slowed to a crawl for several days, then it hit me what “Immunize” meant. Deleted entries in the Hosts file and bam!, right back up to normal computer speed again.

Thanks for the data! That’s really useful.

A couple of questions: what platform is this on? And which memory metric are you using? And what’s the difference between the “Adblock” and “enabled Adblock” columns?

Windows 7 64bit. I restart Firefox with the webpage in one tab. After a minute I look at the windows taskmanager and just take 64.000K as 64MB. I use two portable Firefox versions with one having adblock. Adblock enabled means that Adblock is active. So the Adblock column is just loading the extension but not using it to render the page.

people still using addblock plus?
i liked it but whats behind realy not
As the EFF say on their prism-break site, the reason adblock plus is not recommended is because acceptable ads are on by default which goes against the purpose of the addon itself.
use addblock edge since then – dont know about performance

The “purpose of the add-on itself” is to block invasive and annoying ads, to disincentivize ad networks from creating them and content creators from partnering with the ones that do create them, so no.

Tested with
– adblock plus
– adblock edge
– vanilla

edge and plus have the same problem on the test page specified in the blog.

AdBlock Edge is a fork of AdBlock Plus that has removed the enabled by default “good ads” whitelist in AdBlock Plus.

I use request policy (the 1.0 beta which supports blacklist mode in addition to whitelist mode) to block cross-domain requests. This easily gets rid of most ads (also social embeds and user trackers) without injecting a stylesheet into pages.

It also means those cross-domain iframes don’t get created in the first place, which should actually reduce the memory footprint, although i haven’t verified that with measurements.

I also think this is a small price to pay if you have plenty of RAM, though it would be good if the plugin developers would come up with something that can mitigate this problem.

It would be nice if privoxy were easier to set up. That at least quarantines any memory issues to another box. I think it has a smaller memory footprint too.

If someone offered remote privoxy service for $5/month, I’d probably sign up for it.

That being said, I’ve felt AdBlock in Safari works without noticeable problems if you have 16GB RAM. Not so much if you have 4GB.

GM scripts are generally slower to load than add-ons. Which is why I don’t use GM ad-blocking scripts (disclosure: I’m the author of a script that blocks some Google ads but I often see those same ads coming in, then flashing back out on page load). Seems the only workaround is to hide all the CSS until the DOMContentLoaded event fires (I’m actually going to try this soon in my own script since I never knew before now that there’s a workaround):

But I’m thinking hiding all the CSS until a script loads might slow down the perception of how fast the page loads, either way…

Offtopic – but regardless of what the memory consumption. I think any hacker / coder / webmaster, should never use adblocking if they know how it harms revenue for a user’s site.

IMO if you’re not seeing ads, you’re simply trying to cheat the system.

To be clear what you’re really saying is that I should be ashamed of myself for breaking your business model, which I am most certainly not.

The internet advertising industry has long since lost their social license to operate. As long as they continue to develop more and more obnoxious ways to obstruct our use of the net, they’ve no chance of recovering it and I’ll shed only tears of joy as I update my block set.

Well said. So glad I’m not the only one thinking this. Using ad blockers is morally equivalent to software piracy. Good websites don’t just appear out of thin air – they’re written by people who in many cases want to be paid.

So glad you made that analogy, because there’s absolutely nothing morally wrong with pirating something you wouldn’t’ve paid for anyway.

Glad to see that there seems to be some discussion in the bug about ways for Mozilla to help Adblock Plus fix the issue; unfortunately addons can only use the APIs that are available, so often sub-optimal options have been taken.

Given the large-ish user base, sometimes I feel like Mozilla would be able to serve its users better by actually allocating people towards developing Adblock Plus (or a replacement) directly, in the way Honza does Firebug (plus the whole built-in devtools thing). This, of course, would be difficult for the parts of the organization that need to interact with the advertisers; it would need to be described more as punishing the user-hostile ones (including in cases that affect privacy)…

I did a little check with the latest Chrome canary build.
I’ve been having huge problems with performance on chrome since a few chrome updates ago.

Adblock plus does indeed use more memory:
190 mb vs 1 gb

But my issue with ram consumption is second priority to performance.
The amount of cpu use caused by adblock is unacceptable.
Due to how chrome works now, after the update, will cause several tabs in the same process and even sometimes the whole browser to hang up for a few seconds.

Based on how much google wants to block adblock extensions. I can’t help it to speculate if this was by design. To annoy users into disabling it. Giving adblock a bad reputation of causing performance issues.
Wouldn’t be the first time google/chrome have actively hindered extension developers.
Can anyone with more insight into the chrome code base comment on this?

I had a theory that adblock was picked on:
I noticed other extensions that use the same techniques also cause ram and performance issues.
Such as Stylebot (without any css styles, clean install)
190 mb vs 780 mb

My conclusion to this little test is that the browsers need to be fixed. Updated to support and improve performance for what popular extensions are doing.
Extensions can only use what the browser gives them. Which for at least chrome is nothing but breadcrumbs (unusable, severely limited, unstable and broken api’s)

Extensions such as adblock should not be blamed for what is out of their control.

I would take what he say with a grain of salt.

Doing anything on a computer is cpu/memory intensive. Even just being turned on is “cpu/memory intensive”.
For example the chrome background updater always use 100% of one of my cores when it runs.
That syncing feature even have bandwidth concerns for those poor buggers that have an artificial capacity limit.

In the end it is about balance eg performance vs features. That is not what Chrome is about. If chrome adds adblock feature that means there is a feature google can’t add that also takes up equal amount of cpu/memory time.

This is one of the reasons I can guess chrome do not have adblocking or a more general thing built in.
Google wants those precious times-slots for themselves to do as they please with.

In a twisted way it would also say: “Google supports you blocking our obnoxious time-wasting ads.”
At least that is how they will twist it as an excuse to not implement such a feature. One of the excuses anyway.

Listening and acting on it in proper common sense way to feedback is blaspheme for companies.
“They are blocking our ads. They say they are in the way, too many and obnoxious. What should we do? Add more ads!!!”

Forgot to mention what test page I used:

Off topic rant:
How come it is always the extension that gets the blame?
If you want to point the finger and play the blame game then you should point the finger at the browsers.

Both mozilla and google have statistics of which extensions are popular and could have easily adapted and optimized both the browser and the extension api for better performance for them.
Perhaps even implemented the extensions features directly into the browser.
*hint hint*

Firefox with adblocking feature built in. I can see the news articles already.
But based on the recent ceo mess I don’t think Mozilla got the balls to do such a thing. In fact what is the word for the opposite of balls? That is what mozilla is.
And that was just from some angry whiners.
What would mozilla do if scary multi-million dollar advertisement companies started to whine and throw a tantrum? Implement ads directly into the browser? Oh right… The homepage / startpage ads.

I’m not ambivalent. Ghostery explains this collection (“Ghost Rank”) when installed, and it’s disabled by default. If people blow through the options without changing the defaults then they don’t opt in. I’d be ambivalent about Ghostery if they changed it to opt-out.

If you’re like me and just want to disable popups and don’t care about actual ads, just set dom.popup_allowed_events to an empty space.

Another alternative to try is my PAC filter plus a blocking hosts file. You will need to change the listener to for Windows. The problem is my priorities are much different than ABP:
1. Trackers
2. Malware
3. WebBugs (phish, redirectors, et al)
4. ads (a distant fourth but most are in hosts file, not PAC filter)
There are no overlays and it is quite efficient but no listener for port 443 (https) requests. I think the FanBoy people pulled the plug too soon. Their filter sets were much less intensive. 400 frames? Isn’t that an abuse? It is sure to be a killer for Droid and iPhone or people with minimal old single core CPUs. Somebody creating something like that should be shot.
But the short answer to your question is, can ABP be made more efficient? Yes but only marginally Use a less intensive filter set like FanBoy-AdBlock and Fanboy-Tracking. The problem is, who is going to bring it back?
But my backing up of my files onto an external USB hard disk drive makes your measely 400 MB sound trivial. Use of free -m reveals 6210 used and and 5794 free on a 12 GB machine. What is eating up most of that memory? Disk caching. Firefox is only using about 376 MB. Closing the browser reclaims the memory. I have no idea how to recover from that “cp -rup” or “diff -r –brief” except to reboot the machine. It must do something to reclaim because I have never run out.

I think I cannot just walk off and leave it at that. I am very good with lots of computer languages including C and LISP. Recursion may be fine in an academic setting but when you get out into the real world the heavy load recursion puts on the stack and the CPU is something you usually avoid, especially in one million plus LOC. I have been able to unroll the recursion into iteration successfully almost all the time.
Why do I mention this? Because frames are the equivalent of recursion in the browser. You are looking at just the memory but I can tell you that the increased CPU usage is tremendous. While at this web-site Firefox is always near the top in top (Linux). What happens when I leave this page? Firefox drops down so low most of the time it isn’t even in top. Why do you think hackers use a frame exploit? It keeps your CPU busy while they slip you the mickey (the malware).
Ergo, rather than criticize ABP make your page layouts so that if possible they don’t use frames. Don’t tell me it cannot be done. Just like recursion being replaced by iteration once you understand how to do it, going without frames is possible. If nothing else the exercise in trying to eliminate frames even if you don’t achieve it will develop your thinking skills.
The PAC filter is NOT a plugin and it doesn’t have a layer in every frame. It is just sort of there. But pattern matching stops at a “#” or a “?” and it isn’t going to change. I have enough FPs as it is. Yes, it blocks most ubiquitous ad-servers but stops there. Some people have elevated blocking ads to too high of a level. I really am considering a rule for those
“11” folders at the domain level. It is really nasty malware.

@ Nicholas Nethercote,

” ‘Simply’ reducing Firefox & AdBlockplus memory usage with ±62% on the vimcolorschemetest -page”

Your news has reached Holland as well, ;-), some guy (me) looked at the problem you mentioned, did cost me several days.
I can tell you I did not found out exactly which rules are exactly the biggest problem but I came at least nearby in a way.
Actually I did found out is there is a workaround, for people that don’t want to wait till the so called ‘bug’ isssue is fixed by Mozilla or maybe the AdBlockplus team, maybe. You can find the posting with some of my ‘research results’ here, on a Dutch security and privacy related issues website.
Just look at it. No link spamming, no commercial intentions, just some test results and conclusions.

Yes, it’s in the Dutch language, but you’ll probably work out something with a translation service, I guess so. If that’s not working for you, I’ll be prepared tot consider translating it in English (some more extra work although).

My mentioned memory usage statistics in the posting are a bit higher, probably because I did not disable some other addons like NoScript or Ghostery but you will get the ‘relative memory stats picture’ anyway, I hope (wild guess ;-).
Generally spoken, if you don’t want to learn Dutch, you can work around the issue by better managing or looking at your activated Filter subscriptions. Main problem (I think) is the most & mainly used Easylist filter with probably 42500 rules in it.
But, this filter contains at least 7 sub-filters, removing just one of those filters, the one named “Easylist General element hiding rules” (also the first one actually) will do the ‘memory usage collapse-hocus-spocus’. ‘Problemo’ solved (± 62% lower)

“Yeah, right; disabeling filter rules will give you more advertising!” You would say / think?
No, not that is not my experience yet. Acceptible results, but you have to try it yourself, best way.
Beside, just look at option G in the posting, a combination of different filters to compensate (a little, yes different purpose filters, i know) the deletion of about 14000 rules by adding some 10.000 other ones.

Beside that, just using Noscript and usually blocking iFrames will help a lot too (I think, because a lot of advertising is using iFrame functionality. Which is also a security concern by the way).
Also a firewall with several hundred of advertising domains blocking rules will allmost make you even don’t need ABP anymore. 😉

About the ABP moneymaking whitelist discussion, I actually don’t see any whitelisted advertising coming by during my daily browsing activities. So maybe some people are paying a lot of money to get on a whitelist, still I don’t see them anyway. ‘Sorry you guy’s, don’t hate advertising by the way, just don’t like bad advertising or distracting hocus pocus that is making it impossible for me to actually read content, the first motivation why I am visiting some webpage (not the ads).

One more thing, the example of the googlecode page is extreme. Good for research but not really comparable with more regular daily pages.
Well at least in Europe, because there is a very huge difference between commercial European pages and American pages. You can usually see that by the amount of page trackers and the amount of connections you have to make make to a (very) lot of different domains.
The higer the advertising, tracking and many connections ‘hocus pocus’, the higer the memory usage will be. But that’s probably not done (in the V.s.) to talk about that (What about good website behaviour? Tasteful advertising. Consider separate advertising pages, I’ll be prepared to look at it, after reading the main content on a page, for which is the first reason I am actually there. ;-).

Anyway, as long as you have enough memory / ram there is actually no big issue. Nowadays computers will have at least 4 gb of ram or more.
And Mozilla is always moving foreward; just raise your Mozilla minimum OS requirements and drop some OS versions support and the problem is gone (like they do once in a while, people don’t forget these Mozilla decisions, but thats history for now an not the topic here. Not angry, just sad, once).

So if you have actually a still supported Os by Mozilla, but not enough ram, you do not want to see (too much) advertisements, just consider managing you Filter subscribtions to lower ram usage to an acceptible level.
Or choose the right extra addons.
Or take some time to make a firewall advertising domains blocking rule set and you’ll be happy.

Hopefully this answer did help a bit.

Keep up the research work
Some dutch guy

(@ moderator / p.s, for me; you don’t have to place this answer, please consider to just make this answer is reaching Nicholas, so he can look at the posting-link with some extra information and see if it’s helpful in one way or another. That’s all, thanks in advance).

Comments are closed.