AdguardBrowserExtension icon indicating copy to clipboard operation
AdguardBrowserExtension copied to clipboard

Memory leak

Open s3theweb opened this issue 2 years ago • 26 comments

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.

s3theweb avatar Nov 10 '23 20:11 s3theweb

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.

user31415192 avatar Nov 18 '23 15:11 user31415192

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

alexx7311 avatar Nov 22 '23 14:11 alexx7311

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

s3theweb avatar Dec 01 '23 04:12 s3theweb

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.

pae-id avatar Dec 02 '23 22:12 pae-id

@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 avatar Dec 04 '23 08:12 alexx7311

@s3theweb Is the problem still relevant?

alexx7311 avatar Dec 26 '23 09:12 alexx7311

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.

pae-id avatar Dec 26 '23 17:12 pae-id

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.

Tasiorsa avatar Jan 07 '24 22:01 Tasiorsa

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

Smok07 avatar Jan 14 '24 06:01 Smok07

4.5 GB after 12 hours of browsing Screenshot_8

update: still have this issue after disabling some filters

Smok07 avatar Jan 16 '24 06:01 Smok07

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

Tasiorsa avatar Jan 17 '24 14:01 Tasiorsa

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

alexx7311 avatar Jan 22 '24 11:01 alexx7311

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

Tasiorsa avatar Jan 22 '24 12:01 Tasiorsa

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

pae-id avatar Mar 03 '24 09:03 pae-id

@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.

alexx7311 avatar Mar 12 '24 10:03 alexx7311

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

Tasiorsa avatar Mar 12 '24 10:03 Tasiorsa

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

Tasiorsa avatar Mar 15 '24 12:03 Tasiorsa

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.

pae-id avatar Mar 16 '24 22:03 pae-id

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

Tasiorsa avatar Apr 02 '24 10:04 Tasiorsa

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.

tormozit avatar Apr 20 '24 05:04 tormozit

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

Revertron avatar May 22 '24 22:05 Revertron

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 avatar May 23 '24 14:05 Smok07

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

Smok07 avatar May 25 '24 07:05 Smok07

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.

gaveitatry2 avatar Jul 07 '24 08:07 gaveitatry2