Adblock Plus and (a little) more

On the Adblock Plus memory consumption · 2014-05-15 15:35 by Wladimir Palant

The news is making the rounds that the memory consumption of Adblock Plus can be considerable in some scenarios. While some scenarios mentioned (like the page that requires almost 2 GB of memory) are really edge cases, and unlikely something you will ever see during regular browsing, the issue is certainly real. It isn’t exactly unknown either and we have been looking into ways to resolve it for a while already.

Now, there are really two very different issues mentioned there. One is caused by very non-obvious behavior in Firefox: while Adblock Plus registers a single stylesheet for its element hiding feature, what happens behind the scenes is Firefox creating a new copy of it for each page being loaded (bug 988266). The memory consumption of all these copies can be very significant, like the 2 GB mentioned above for an edge case.

There is some ongoing discussion in this bug, which will hopefully result in a way to remove the duplication in Firefox and have most of the stylesheet data shared between all pages. Beyond that we are working on a feature to let users send us their filter hit statistics (optional and opt-in of course). This data should help filter authors see which filters are actually being used and which can be removed. Reducing the number of filters will also reduce the memory consumption of that stylesheet.

The other issue is the memory consumption of the data structures created by Adblock Plus itself, these are mostly required in order to manage and apply its filters. Current filter lists for Adblock Plus have around 50 thousand filters which (along with supplemental data like filter hits) require around 60 MB of memory. Clearly, that data is stored in a less than optimal way but apparently that’s hard to avoid when working with complicated JavaScript objects.

Of course we are working on identifying unnecessary memory consumption and getting rid of it (see issue 354 for example), but the potential is limited here as long as we stick to JavaScript objects. So instead we want to implement our own way to store data, a project that will hopefully be finished soon. That approach should also improve performance in the long term though it’s not quite clear yet how well the new code will perform.

Tags:

Comment [23]

  1. Rorto · 2014-05-15 17:19 · #

    To get rid of this problem, i am currently testing Privoxy.
    For easy set up, I have used this script:
    https://github.com/skroll/privoxy-adblock

  2. Alexander Peter Kowalski · 2014-05-15 17:56 · #

    This comment originally contained tons of off-topic text paired with advertising for own solution. Short version: host files are better than Adblock Plus.

  3. yeah okay · 2014-05-15 18:32 · #

    Just admit that it’s Mozilla’s fault for not rushing to replace gecko with servo and replace spidermonkey with a better js engine in rust.

  4. indy · 2014-05-16 00:49 · #

    APK:

    Host-based blocking doesn’t hide elements(which otherwise makes pages very ugly and might as well not bother), and some ad-networks are self-hosted, which host-based blocking can’t work around.

    An example is my favorite 10 sites I element hide about 70 different elements of the pages to make browsing much more efficient.

    Thanks for what you do, though, it does have its uses in many other scenarios!

  5. Alexander Peter Kowalski · 2014-05-16 02:56 · #

    Does for me in IE 10/11 + as far back “old” as Opera 12x & earlier series (way, Way, WAY back – but I can control a lot on Opera more easily, see below for more details).

    So – What browser is that? Sounds like early IE.

    I tested it on IE 11 32/64 here (& 10/9 before it) & have no such issues.

    I don’t on Opera 12.15 here either.

    FireFox thru TONS of versions never did.

    Check your settings in your browser on frames or being able to see placeholders (I’ve seen that in IE before in earlier models, iirc 8/9 0 for security + compatibility purposes, seriously: Upgrade your IE to @ least 10-11 for your own sake)
    .
    APK

    P.S.=> I think THAT is your “cure” (should/will work) above I believe, & you’re welcome – hosts files do FAR more than ANY SINGLE BROWSER ADDON out there bar-none with less overheads & moving parts complexity & more control locally AND also secure you vs. DNS issues + trackings @ that level too no less – “multiple bonus” + from a FASTER kernelmode subsystem vs. piling on more slowing it down MORE slower usermode ‘solutions’ in browser addons working LONG BEFORE THEY CAN EVEN BEGIN TO START OPERATION – always early to work, vs. late, on any platform bearing a TCP/IP stack in BSD std. design form including hosts, which is 99.999% of them, runs anywhere & everywhere too)… apk

    Reply from Wladimir Palant:

    I am removing your comments – this isn’t the place to discuss advantages and disadvantages of host files. Please don’t post off-topic comments on this blog.

  6. Alexander Peter Kowalski · 2014-05-16 04:49 · #

    Additionally: On Self-Hosted Ads – How many of those are there as opposed to NON Self-Hosted Ads & why? Advertisers don’t TRUST website webmasters etc. on reports of clickcounts THEY would provide them, would you? Probably not if it was your money. That’s why ads are setup the way they are, & always will be, on that end. Can’t find an answer to why things are the way they are? The answer’s money. No… you’re representing a variable in a equation that has VERY LITTLE WEIGHT/BEARING here… my guess @ most, is that self-hosted ads represent MAYBE 1% of all ads, and certainly that they don’t pay (or near as well minus costing the website money serving up said ad + code & data etc. plus tracking etc. ontop of it – you know, the bogus bandwidth robbing tracking crap that takes YOUR bandwidth from you that YOU paid for with YOUR money…)

    APK

    P.S. – Think about that & good day – your 1 issue in placeholder display was fixed or is an EASY fix for you (upgrade & placeholder settings easy) & this is truth here on that other objection of yours is all… apk

  7. Ferdinand · 2014-05-16 09:21 · #

    Using 100MB for adblock is okay to me if it stays at that level. The main problem in Firefox is that it becomes slow at 1+GB and adblock memory usage gets you there faster. I use UnloadTab to keep Firefox memory usage down to at most 700MB.
    Why does it use about 190MB in Chrome?

    Reply from Wladimir Palant:

    Up to 100 MB memory usage (if you don’t count spikes caused by temporary objects) is what I know as well. Memory use that’s significantly larger than that would indicate a memory leak but we aren’t currently aware of any in Adblock Plus – maybe some other extension interferes.

  8. George · 2014-05-16 21:17 · #

    Wladimir, it is good news that there’s a chance that the situation can be improved (even if not completely fixed).

    Until then, for when I’m using a machine with little memory:

    1. Does choosing “Disable on this page only” prevent high memory use on that page? (I heard that the answer is no.)

    2. Does choosing “Disable everywhere” prevent high memory use in general (without restarting Firefox)?

    And finally: is the Chrome version of Adblock Plus affected (though I woulnd’t use Chrome on a machine with little memory as I find Firefox performs much better memory-wise …)

    Reply from Wladimir Palant:

    If you are talking about the styles issue – disabling Adblock Plus everywhere “fixes” it, disabling on a particular site doesn’t (the way this works in Firefox there cannot be exceptions for individual websites). Chrome is similarly affected, disabling Adblock Plus on a website there prevents style injection however.

  9. nnethercote · 2014-05-16 22:37 · #

    I tried (1), and it doesn’t appear to have any effect.

    I haven’t tried (2), but I did try simply disabling ABP via Firefox’s add-ons manager, and that caused memory usage to drop immediately.

    I haven’t tried Chrome, but I’ve read in several places that ABP for Chrome also uses a lot of memory, though the effects are not identical.

  10. geppetto · 2014-05-18 00:08 · #

    How much is this affecting the ABP android version? Even with the (ram efficient) rooted cm4.4.2 it consumes a lot of RAM which is super precious at mobile phones…
    Will you also provided an updated .apk after any kind of optimisation? :-)

    Reply from Wladimir Palant:

    The stylesheet issue doesn’t affect Android. However, the general memory consumption of Adblock Plus is relatively high there as well – that’s the main reason why https://issues.adblockplus.org/ticket/145 exists. That work is much more important for mobile than for the desktop browsers and of course we will update Adblock Plus for Android as soon as it is done.

  11. Andrew Ducker · 2014-05-19 14:01 · #

    Is there any reason why ABP couldn’t put in a filtered list to each page?

    I’ve just seen this:
    https://github.com/gorhill/httpswitchboard/wiki/Adblock-Plus-memory-consumption

    and it seems like a good alternative approach that would save massively on memory.

    Reply from Wladimir Palant:

    It’s because roughly 60% of the filters currently in EasyList are meant to apply on all webpages so this kind of filtering wouldn’t help much. Of course one could go there and implement an intentionally broken approach in order to claim that the performance is great if “87% of the filters” work. Fact is, with this implementation only the most simple filters are supported and even that support is very incomplete for pages that change dynamically.

    Note that the memory issue this is trying to solve isn’t very significant – except on very few webpages.

  12. Mikhoul · 2014-05-19 18:15 · #

    Hi Wladimir,

    I use ABP since many years… over the time/years I subscribed to many list and I’d like to know which one I really need keep to minimize the redundancy in the filters ???

    Here’s the one I use from a screen shot: http://i.imgur.com/oJrnQiG.png

    Thanks for ABP & element hiding helper :)

    Reply from Wladimir Palant:

    Your lists are actually perfectly fine – no redundancy there, each of them covers its own feature.

    Note that I am removing this comment because it is off topic.

  13. Andrea Martinelli · 2014-05-19 22:00 · #

    Here’s EasyList stripped out of all its CSS rules.
    It will miss some banners, but most of them are still blocked.

    http://www.xamasoft.com/adblock/easylist-nocssrules.txt

    Reply from Wladimir Palant:

    Or simpler: https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt. Seems that it isn’t linked from the subscriptions list any more.

  14. Anon · 2014-05-27 02:29 · #

    Similar to how you’re being paid to permit acceptable ads, my guess is that you’re intentionally doing nothing to improve the performance of adblock so as to cause people to disable it out of frustration.

    Reply from Wladimir Palant:

    Wow, conspiration theories at its best. Fortunately, this is my blog and I have no obligation to leave every ridiculous accusation standing here.

  15. James Edward Lewis II · 2014-05-28 22:23 · #

    Does the use of Shadow DOM in the Chrome version of the extension improve memory usage, compared to injecting a stylesheet normally? I’m switching back from AdBlock to ABP to check, because I noticed AdBlock hasn’t used Shadow DOM yet, even though ABP does not perform the null-content redirection (image to 1×1 transparent PNG, document to about:blank) that AdBlock performs.

    Reply from Wladimir Palant:

    No, the Shadow DOM should have no impact on the memory use whatsoever.

    ABP hides blocked elements by other means, redirecting is generally problematic due to potential conflicts with other extensions.

  16. CBA · 2014-05-29 09:58 · #

    https://easylist-downloads.adblockplus.org/easylist_noelemhide.txt

    The above doesn’t combine well with a supplementary list, like EasyList Germany, which requires the full EasyList. What I need is an EasyList “compact” (or short version), as the full EasyList is too large. Is there such a thing like “compact”?

  17. James Edward Lewis II · 2014-05-29 12:11 · #

    Rorto, I think I got that updater script working on Windows using JScript; the only dependency is sed, but the script can be refactored to use only the native capabilities of the Windows Script Host: https://github.com/lewisje/privoxy-adblock-jscript

  18. K.L. · 2014-06-07 05:34 · #

    CBA,

    You might want to try out “Easylist – NoMercy”. It’s compact than Easylist. I found it on Adblock Edge.

    List URL: http://pie.sw.gs:1223/data/abl/nm_easylist.txt
    Edge: https://bitbucket.org/adstomper/adblockedge/issue/78

    Reply from Sebastian Noack:

    It seems that it’s author confused Acceptable Ads with the whitelisting rules in EasyList, which exist to work around known issues. However, there are no Acceptable Ads whitlisted in EasyList. They are whitelisted by a separate filter list. So EasyList NoMercy will essentially just break some websites.

  19. Пользователь браузера TOR · 2014-06-07 14:14 · #

    Купить JWH в любой точке России — ICQ: 481838083 (доставка из Москвы)

    Метилендиоксиметамфетамин (экстази)
    Цена:
    1 г — 2000 р. (2000 р. за г)
    3 г — 4500 (1500 р. за г)
    5 г — 6500 (1300 р. за г)
    10 г — 10000 (1000 р. за г)
    25 г — 20000 (800 р. за г)

    Спайс (россыпь, твердый)
    Цена:
    3 г — 1500 р. (500 р. за г)
    5 г — 2000 р. (400 р. за г)
    10 г — 3500 р. (350 р. за г)
    25 г — 7500 р. (300 р. за г)

    Реагент (JWH-18, JWH-307, MN-35)
    Цена:
    1 г — 1900 р. (1900 р. за г)
    3 г — 5500 р. (1833 р. за г)
    5 г — 8500 р. (1700 р. за г)
    10 г — 12000 р. (1200 р. за г)

  20. AnonyMice and AnonyMen · 2014-06-14 23:20 · #

    Adblock Plus can use up to 60M? Pft.

    Without Adblock Plus on a fresh profile, Firefox uses some odd 150M. Doing nothing but installing Adblock Plus and fetching the EasyList filter I am seeing usage upwards of 300M.

    Granted, it’s 2014, I have the memory. But I think this is an understatement.

  21. Bob · 2014-06-16 11:06 · #

    Why is this feature enabled by default?

    Unfortunately, this is the only way to accomplish the goals described above.

    Get fucked you faggots you are just as bad as the ad companies what a piss poor excuse.

  22. matthieu · 2014-06-16 13:10 · #

    Hi,
    Adblock Plus + Firefox crashes on Facebook.
    It seems like they do not like the element hider either, but crashing your browser (“firefox has to close” and all) is a hard counterattack…

    Other than that, and with a recent computer, the memory consumption is not that much of a problem to me.

  23. CelticManiac · 2014-06-25 15:37 · #

    It’s been 40+ days since your blog post. any updates? I understand that both mozilla and abp have homeworks of their own to do so updates from any would be welcome news for abp fans

    Reply from Wladimir Palant:

    We are making progress but it really isn’t that simple. E.g. concerning the stylesheet memory issue, Tom Schuster created a patch in https://bugzilla.mozilla.org/show_bug.cgi?id=1024707 that will hopefully make it into Firefox soon. This will allow improvements on our end with backwards compatibility being the tough part here.

Commenting is closed for this article.