dhowe / AdNauseam

AdNauseam: Fight back against advertising surveillance
GNU General Public License v3.0
4.52k stars 189 forks source link

firefox extension memory leaking #2233

Open shanechko opened 1 year ago

shanechko commented 1 year ago

After day of usage firefox 107 extension process use more 2g RSS memory. 95% used by js strings for AdNauseam extension.

about:memory extension (pid ****) Explicit Allocations

2,728.46 MB (100.0%) -- explicit ├──2,639.56 MB (96.74%) -- window-objects │ ├──2,632.66 MB (96.49%) -- top(moz-extension://717f556c-13e8-4d1d-94ef-d275f50f51a8/background.html, id=28) │ │ ├──2,615.75 MB (95.87%) -- js-zone(0x7f8eba454c00) │ │ │ ├──2,612.74 MB (95.76%) ++ strings │ │ │ │ ├──────8.00 MB (00.29%) -- string(length=2290504, copies=1, "46/n#block-start-COSMETIC_FILTERS …1500 string are skipped │ │ │ └──────3.01 MB (00.11%) ++ (17 tiny) │ │ └─────16.91 MB (00.62%) ++ active/window(moz-extension://717f556c-13e8-4d1d-94ef-d275f50f51a8/background.html) │ └──────6.89 MB (00.25%) ++ (10 tiny) ├─────32.30 MB (01.18%) ++ js-non-window ├─────29.40 MB (01.08%) ++ heap-overhead └─────27.19 MB (01.00%) ++ (22 tiny)

settings

filter lists

Default filter lists + "RUS".

shanechko commented 1 year ago

I've looked into strings and figured out content is youtube page.

Extension memory usage is normal if AdNauseam is disabled for "youtube.com" site.

mneunomne commented 1 year ago

@shanechko thank you submitting this ticket. I am currently testing in MacOS both in Firefox and Chrome, and for now I see no unusual memory usage in either of them. I'm wondering if it is perhaps a linux-specific issue.

I will check and report back here.

shanechko commented 1 year ago

I've found additional requirement.

You have to use "Russian" version of youtube to reproduce. Showing YouTube RU in top left corner. Also using russian filter list.

Curious.


1,065.72 MB (100.0%) -- explicit
├──1,032.55 MB (96.89%) -- window-objects
│  ├──1,027.34 MB (96.40%) -- top(moz-extension://717f556c-13e8-4d1d-94ef-d275f50f51a8/background.html, id=30)
│  │  ├──1,015.86 MB (95.32%) -- js-zone(0x7f43f9351c00)
│  │  │  ├──1,012.75 MB (95.03%) -- strings
│  │  │  │  ├──────4.00 MB (00.38%) -- string(length=1152381, copies=1, "<!DOCTYPE html><html style="font-size: 10px;font-family: Roboto, Arial, sans-serif;" lang="en" system-icons typography typography-spacing darker-dark-theme><head><meta http-equiv="origin-trial" content="AlgsH67ctYlMR3JYAxEnGfvsoFo41AMqAg6wRHHXOpWAfD54ZCfTPBclxnFT4Gc8IUX4pq6Xfo0esDuOt+WH3wIAAABteyJvcmlnaW4iOiJodHRwczovL3lvdXR1YmUuY29tOjQ0MyIsImZlYXR1cmUiOiJQcml2YWN5U2FuZGJveEFkc0FQSXMiLCJleHBpcnkiOjE2ODA2NTI3OTksImlzU3ViZG9tYWluIjp0cnVlfQ=="/><script nonce="16WafSzpIk5wImfx8C7XSg">var ytcfg={d:function(){return window.yt&&yt.config_||ytcfg.data_||(ytcfg.data_={})},get:function(k,o){return k in ytcfg.d()?ytcfg.d()[k]:o},set:function(){var a=arguments;if(a.length>1)ytcfg.d()[a[0]]=a[1];else for(var k in a[0])ytcfg.d()[k]=a[0][k]}};/nwindow.ytcfg.set('EMERGENCY_BASE_URL', '///error_204?t//x3djserror//x26level//x3dERROR//x26client.name//x3d1//x26client.version//x3d2.20221207.05.00');</script><script nonce="16WafSzpIk5wImfx8C7XSg">(function(){window.yterr=window.yterr||true;window.unhandledErrorMessages={};window." (truncated))
mneunomne commented 1 year ago

Interesting. I don't think I can reproduce it since I don't have vpn for Russia. @shanechko could you perhaps check if the same thing can be reproduced with uBlock Origin? Perhaps the issue lays with this specific list.

shanechko commented 1 year ago

@mneunomne uBlock Origin works with negligible memory usage.

mneunomne commented 1 year ago

We need to automate this testing so we can reach a conclusion.

https://media-codings.com/articles/automatically-detect-memory-leaks-with-puppeteer

Slater91 commented 8 months ago

I see the same issue and I don't use YouTube in Russian. I am on Linux, however. This is what appears in the memory report:

588.70 MB (80.26%) -- strings
│  │  │  │  ├──210.52 MB (28.70%) ++ (317 tiny)
│  │  │  │  ├───10.18 MB (01.39%) -- string(<non-notable strings>)
│  │  │  │  │   ├───8.80 MB (01.20%) -- malloc-heap
│  │  │  │  │   │   ├──7.95 MB (01.08%) ── two-byte
│  │  │  │  │   │   └──0.85 MB (00.12%) ── latin1
│  │  │  │  │   └───1.38 MB (00.19%) ++ gc-heap
│  │  │  │  ├────8.00 MB (01.09%) -- string(length=2111734, copies=1, "<!doctype html><html lang="en-us" class="a-no-js" data-19ax5a9jf="dingo"><!-- sp:feature:head-start -->/n<head><script>var aPageStart = (new Date()).getTime();</script><meta charset="utf-8"/>/n<!-- sp:end-feature:head-start -->/n<!-- sp:feature:csm:head-open-part1 -->/n/n<script type='text/javascript'>var ue_t0=ue_t0||+new Date();</script>/n<!-- sp:end-feature:csm:head-open-part1 -->/n<!-- sp:feature:cs-optimization -->/n<meta http-equiv='x-dns-prefetch-control' content='on'>/n<link rel="dns-prefetch" href="https://images-na.ssl-images-amazon.com" crossorigin>/n<link rel="preconnect" href="https://images-na.ssl-images-amazon.com" crossorigin>/n<link rel="dns-prefetch" href="https://m.media-amazon.com" crossorigin>/n<link rel="preconnect" href="https://m.media-amazon.com" crossorigin>/n<link rel="dns-prefetch" href="https://completion.amazon.com" crossorigin>/n<link rel="preconnect" href="https://completion.amazon.com" crossorigin>/n<!-- sp:end-feature:cs-optimization -->/n<!-- sp:feature:csm:head-open-part2 " (truncated))
│  │  │  │  │    ├──8.00 MB (01.09%) ── malloc-heap/two-byte
│  │  │  │  │    └──0.00 MB (00.00%) ── gc-heap/two-byte
│  │  │  │  ├────8.00 MB (01.09%) -- string(length=2112139, copies=1, "<!doctype html><html lang="en-us" class="a-no-js" data-19ax5a9jf="dingo"><!-- sp:feature:head-start -->/n<head><script>var aPageStart = (new Date()).getTime();</script><meta charset="utf-8"/>/n<!-- sp:end-feature:head-start -->/n<!-- sp:feature:csm:head-open-part1 -->/n/n<script type='text/javascript'>var ue_t0=ue_t0||+new Date();</script>/n<!-- sp:end-feature:csm:head-open-part1 -->/n<!-- sp:feature:cs-optimization -->/n<meta http-equiv='x-dns-prefetch-control' content='on'>/n<link rel="dns-prefetch" href="https://images-na.ssl-images-amazon.com" crossorigin>/n<link rel="preconnect" href="https://images-na.ssl-images-amazon.com" crossorigin>/n<link rel="dns-prefetch" href="https://m.media-amazon.com" crossorigin>/n<link rel="preconnect" href="https://m.media-amazon.com" crossorigin>/n<link rel="dns-prefetch" href="https://completion.amazon.com" crossorigin>/n<link rel="preconnect" href="https://completion.amazon.com" crossorigin>/n<!-- sp:end-feature:cs-optimization -->/n<!-- sp:feature:csm:head-open-part2 " (truncated))
│  │  │  │  │    ├──8.00 MB (01.09%) ── malloc-heap/two-byte
│  │  │  │  │    └──0.00 MB (00.00%) ── gc-heap/two-byte

As you can see, in my case it seems like Amazon is the culprit.