AdguardTeam / AdguardBrowserExtension

AdGuard browser extension
https://adguard.com/
GNU General Public License v3.0
2.99k stars 320 forks source link

Memory leak #2594

Open s3theweb opened 10 months ago

s3theweb commented 10 months ago

AdGuard Extension version

4.2.209

Browser version

Firefox 119.0.1

OS version

Windows 11

What filters do you have enabled?

AdGuard Base filter, Filter unblocking search ads and self-promotion, AdGuard Russian filter, AdGuard Chinese filter, AdGuard German filter, AdGuard Japanese filter, AdGuard Spanish/Portuguese filter, EasyList Italy, Liste AR, EasyList Thailand

What Stealth Mode options do you have enabled?

Not enabled

Issue Details

Over the course of about day or so most tabs will trend towards using a gigabyte or more of memory usage. It seems to be worse on pages where things are actually blocked, but even the most basic websites like example.com will use up hundreds of megabytes of memory when left open for a period of time. The google search homepage grows in memory usage almost 5 times faster than example.com Disabling the adguard extension fixes it.

I found that it was Adguard specifically because a javascript memory snapshot on any tab showed hundreds of megabytes allocated to scripts within the extension.

Expected Behavior

Basic pages should not use a gigabyte of memory.

Screenshots

Screenshot 1:

image This is a javascript memory snapshot of example.com and moz-extension://3aeeed36-... is Adguard's extension path. Example.com has no javascript of its own.

Additional Information

I am running Firefox and I also have uBlock origin, ghostery, tamper-monkey(which does not have any global scripts), and dark reader(not enabled for tabs in question) installed. This only started happening a few weeks ago and I had not installed or removed any extensions.

user31415192 commented 9 months ago

From @gorhill of uBlock Origin:

Do NOT use uBO with any other content blocker. uBO performs as well as or better than most popular blockers. Other blockers can prevent uBO's privacy or anti-blocker-defusing features from working correctly.

So you got three blockers all running at once: uBlock Origin, Ghostery and AdGuard. From the quote above, we can deduce that it's a bad idea to have multiple blockers running concurrently, as they don't play well with each other; therefore, I strongly recommend keeping only one of those blockers, while the others must go.

Also, for this same reason, this issue is INVALID and shall be closed ASAP.

alexx7311 commented 9 months ago

@s3theweb Please check if the problem persists on the latest beta build for Firefox https://agrd.io/extension_firefox_beta

s3theweb commented 9 months ago

I agree with user31415192 that having multiple blockers like this is not ideal, but because this happens in the page's JavaScript theoretically it could be triggered by some script on a page if it does something similar to what the other extensions are doing.

I tested on the latest beta build and still got the same behavior. Example.com got up to over 2GB of ram usage over a few days. And the extension ID for the offending scripts is the one associated with the beta extension. image

InQuize commented 9 months ago

I can confirm, had memory leak issues and AdGuard is the only global adblock active. To my surprise, there was exactly 24GB of RAM consumed by 'Extensions' in about:processes, haven't made screenshot then (was too quick to prevent next Firefox crash), but it should not be a problem to reproduce if no change was made.. All that RAM was immediately cleared as soon as I started to toggle extensions off-on starting with AdGuard.

Not sure if it goes up with the number of visited tabs or proportional to time they were active or both, but I utilized manual tab unloading recently, this way seems tame, will keep an eye on it.

alexx7311 commented 9 months ago

@s3theweb The beta version of the Firefox extension contains a fix that addresses an issue potentially causing a memory leak. This may be a different case. What steps do you take to reproduce the problem?

@InQuize This problem should be fixed in the beta version. Please check if the problem still persists on the beta version of the extension.

alexx7311 commented 8 months ago

@s3theweb Is the problem still relevant?

InQuize commented 8 months ago

My problem might be different in that RAM per tab is relatively low, all tab proccesses are ~1GB (e.g. group of youtube tabs) or less. The overall 'Extensions' RAM utilization is quite high, only growing at unknown rates and seems to freed the majority of it only upon reboot, restart or AdGuard extension off-on toggle, like on screenshots below:

mem-usage mem-reset I have a bunch of tabs and windows across 6 virtual desktops and 2 monitors, and 2-4 weeks usual uptimes. This one was over 15d.

I monitored following figures over last weeks: ext v4.2.209 - 24GB, Win begins to kill processes, preventive extension toggle off-on cleares all ext v4.2.209 - 11GB, Firefox crash ext v4.2.209 - 6GB, toggle off-on cleares all, switch to standalone from this thread (w/o Firefox restart if it matters) ext beta v4.2.240 - 9GB peak, 8GB at time of Firefox crash, switch to v4.2.240 release (with OS restart) ext v4.2.240 - preventive toggle off-on with screenshots above

When I restart AdGuard plugin, 'Extensions' consumption always drops to 100mb or less down to a bottom of RAM sorted list, while there are no negative effects on already opened tabs or new ones, everything works as expected and looks like issue with garbage collection rather than memory leak.

Tasiorsa commented 8 months ago

I have exactly the same problem. Firefox eats 14 GB per 12 hours and is still growing. I only have 8 tabs open. Tested on release version and standalone. When I disable Adguard or change to uBlock everything looks fine.

Smok07 commented 7 months ago

with adguard - 3GB Screenshot_4 without adguard - 243MB Screenshot_5

Smok07 commented 7 months ago

4.5 GB after 12 hours of browsing Screenshot_8

update: still have this issue after disabling some filters

Tasiorsa commented 7 months ago

Same scenario here 10-12GB per 12h. If I have fewer filters enabled, Firefox uses less memory for eg 4-6 GB per 12h

alexx7311 commented 7 months ago

@InQuize @Smok07 @Tasiorsa Does the problem reproduce when disabling all extensions except AdGuard?

Tasiorsa commented 7 months ago

Yes, the problem occurs on a new profile with only one Adguard extension. Latest test Firefox 121.0.1 & Adguard 4.3.10.

InQuize commented 6 months ago

Does the problem reproduce when disabling all extensions except AdGuard?

Finally had the opportunity to do just that. On v4.3.13 in just two working days (of medium intensity web research) "Extensions" consumption jumped over 7GB.

Prior to that I was running uBlock Origin with all the usual unrelated extensions on and the same metric was floating around 500mb for the whole time of 40d uptime, had zero OOM issues.

2d-1ext

2d-1ext-dis

alexx7311 commented 5 months ago

@InQuize @Smok07 @Tasiorsa Please check if the problem persists on the latest beta version for Firefox at https://github.com/AdguardTeam/AdguardBrowserExtension/releases/tag/v4.3.31-beta We've fixed the possible problem with the memory leak there.

Tasiorsa commented 5 months ago

I've installed latest release https://github.com/AdguardTeam/AdguardBrowserExtension/releases/tag/v4.3.31 Testing in progress :-)

Tasiorsa commented 5 months ago

Memory consumption still increases, but much slower than in older versions. So the improvement is visible.

InQuize commented 5 months ago

I did not notice much difference. At 3GB right now. Issue might be much worse in private mode (and certainly scales the most with the amount of sites visited and/or tabs opened), at least I believe that is how I got initial double digit figures of RAM consumption, but it is just a feeling, I haven't had an opportunity to reproduce it with similar amounts of tabs using private mode yet.

Tasiorsa commented 5 months ago

On Firefox 124.0.1 and Adguard 4.3.35, the problem of high RAM consumption still exists. About 12 GB RAM per 24 hours and constantly increasing

tormozit commented 4 months ago

I confirm. I am using Firefox + AdGuard lastest versions. Since at least begin of 2023 I notice constant memory leaks by AdGurad (visible in memory snapshot in developer tools). Last check made today on Firefox 125 + AdGuard 4.3.46 - I see no change in speed of leaks. So I still need to restart Firefox every day or more frequently.

And memory leaks are not related to sites. I see no pattern in relation of leak with WebSite or with user actions. It seems it has constant speed no matter what is doing user.

And I tried Edge browser with same extension. This problem exists also there.

Revertron commented 3 months ago

I think this bug may be responsible for high memory consumption: https://github.com/AdguardTeam/AdguardBrowserExtension/issues/2792

Smok07 commented 3 months ago

I can confirm that this is indeed a bug #2792 even if user rules are disabled, but your user rules are not empty, a memory leak will occur after deleting user rules, the problem is solved

Smok07 commented 3 months ago

after 3 days - 6.7gb much slower, but still has a problem Screenshot_2

gaveitatry2 commented 2 months ago

I just wanted to report that I had the same problem with AdGuard AdBlocker having an enormous memory leak on Mozilla Firefox (but not Google Chrome). I always had two tabs pinned (Discord and Amazon) and one open tab (offline website). When I restarted the browser, it would use up around 900 MB of memory. But as time passed, even if I did not use the browser at all, the memory usage would keep increasing. It would go up to 2500 MB. Then 4000-4500 MB. And just keep increasing throughout the day. I made it to point the restart my browser as often as possible, at least twice a day. If I didn't, the memory message would just keep incrasing to 8K MB, 16K MB, and so on. Disabling this AdGuard Adblocker extension did the job. But anyway, this memory leak encouraged me to try a new browser so I'm switching from Mozilla Firefox to Google Chrome now. Hopefully this switch will be worth it and I won't have any regrets. But I am thinking that it might have been the right choice.

alexx7311 commented 1 day ago

Does the problem reproduce on the latest 4.4.22 version?

Tasiorsa commented 9 hours ago

Does the problem reproduce on the latest 4.4.22 version?

Windows 11 Pro Firefox 130.0 Adguard 4.4.22 - fresh install Still the same issue - screen after 10 hours - 8 bookmarks ffadg