Open Bug 2051334 Opened 4 months ago Updated 3 months ago

WebExtension process ends up with 3,621 zones in normal use

Categories

(WebExtensions :: General, defect)

Firefox 151
defect

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: bydyx151603, Unassigned)

Details

Attachments

(4 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:151.0) Gecko/20100101 Firefox/151.0

Steps to reproduce:

A long-running Firefox WebExtensions process on Windows grew to around 6-7 GiB private commit.

The memory report showed:

private: 6548.9 MiB
resident: 863 MiB
explicit: 624.3 MiB
js-main-runtime-gc-buffers/free: 5730.5 MiB

I ran about:memory -> Minimize memory usage, but it had no meaningful effect on the WebExtensions process private commit.

I also inspected a process dump offline with a local scanner.

I do not have a minimal reproducer. This was observed in a long-running WebExtensions process.

Actual results:

about:memory -> Minimize memory usage did not materially reduce the WebExtensions process private commit.

The memory report still showed about 6.5 GiB private commit, with most of it reported as SpiderMonkey GC buffer free space:

private: 6548.9 MiB
resident: 863 MiB
explicit: 624.3 MiB
js-main-runtime-gc-buffers/free: 5730.5 MiB

The offline dump scan found SpiderMonkey BufferAllocator::FreeRegion-like structures totaling about 5.58 GiB:

freeRegions: 13768
freeBytes: 5854679040 bytes
freeBytes: 5583.5 MiB
hasDecommittedPages: 13727 / 13768

This closely matches:

js-main-runtime-gc-buffers/free: 5730.5 MiB

The retained memory therefore appears to correspond mostly to SpiderMonkey BufferAllocator free regions, not live JS data.

Expected results:

about:memory -> Minimize memory usage should release very large SpiderMonkey BufferAllocator free regions from Windows private commit where possible.

Keeping about 5.6 GiB of BufferAllocator free memory charged as private commit after minimization seems unexpected.

The Bugbug bot thinks this bug should belong to the 'Core::JavaScript Engine' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Component: JavaScript Engine → JavaScript: GC

Thanks for the report.

This may have been fixed by bug 2045637 which addressed a similar problem.

The fix landed in version 153. Reporter, could you test on nightly or beta and see if this still happens for you?

Flags: needinfo?(bydyx151603)

Okay, I couldn't find any related titles, so I don't know. Also, since I've been running it continuously, that's how I discovered this “memory leak” issue, so the version hasn't been updated.
I don't know how to reproduce it, because I don't even know which extension allocated and then released the memory, so I can't test it against the new version either.
I wanted to reproduce it using HTML, but I couldn't reproduce it in 151b10. It seems to only happen in the extension process?
Note that I haven't closed the extension process yet, and I've also taken a full dump of it.

Flags: needinfo?(bydyx151603)

Also, I've noticed that it doesn't seem to have increased rapidly on any single day; rather, it has been increasing gradually (since I've watched it slowly climb to the highest number of commits). I'm not sure what's going on, but it's been running for about 15 days now.

Severity: -- → S3
Priority: -- → P3

In the last few days, it has increased again, rising to a commit size of 9.5 GB.
I had no choice but to suspend it (I didn’t kill it).
Then I updated the browser in the sandbox (to 153.0b7) and used it normally.
The one in the sandbox seems to be slowly increasing; it started at 204 MB and is now at 1.5 GB.
Current status: js-main-runtime-gc-buffers/*/free (sum): 548.29 MB

(In reply to Xoirer from comment #5)

Current status: js-main-runtime-gc-buffers/*/free (sum): 548.29 MB

Thanks for the update. What's the used size?

(In reply to Jon Coppeard (:jonco) from comment #6)

(In reply to Xoirer from comment #5)

Current status: js-main-runtime-gc-buffers/*/free (sum): 548.29 MB

Thanks for the update. What's the used size?

.used. in 22872 is 254.11 MB.

No, it is
.*used.*

I ran the scraping at different times, and it seems that js-main-runtime-gc-buffers/*/free decreases slightly, but I don't know if it will continue to rise afterward.

(In reply to Xoirer from comment #9)
Thanks for the memory measurements. The free/used look OK but there are 546 zones in the extension process, which likely indicates some kind of memory leak.

(In reply to Jon Coppeard (:jonco) from comment #10)

I'm not sure if this is a memory leak caused by extensions, but what I'm seeing here is that Firefox isn't reclaiming free space.
The amount of free space seems to be much less than in older versions, but is 512 MB considered normal?

If I don't see any more free space, this issue may indeed have been fixed.

But I'm currently on 153.0b8 (because I restarted).
Currently, the .*(allocated|used).* for the extension process is 520.03 MB, and js-main-runtime-gc-buffers/.*/free.* is 733.36 MB.
Is that already more than half?
I suspect this is due to fragmentation. The issue with the decommit not working seems to have been fixed, but if it’s fragmentation, that might not be resolved.

New information has been discovered.
During normal use of 153.0b11, js-main-runtime-gc-buffers/.*/free.* is once again “leaking” a large amount of memory; I suspect this issue may be caused by fragmentation.
The problem doesn't seem to have been resolved.

3260             171.69 MB
3672              45.62 MB
4304                   0 B
4468               2.47 MB
5480               4.50 MB
6208               2.51 MB
7280              10.60 MB
10652              9.86 MB
11564             18.47 MB
12780              3.65 MB
13092             11.09 MB
14492              9.80 MB
14580              3.57 GB // Extension Process
15712              6.99 MB
16180             21.48 MB
17112             50.94 MB
17332                  0 B
17488              1.97 MB
17664             11.04 MB
18892             16.88 MB
19224             76.88 MB
20552             18.70 MB
20816            947.69 KB
20988                  0 B
23432             17.56 MB
24348             16.84 MB
25332              4.83 MB
25416             21.77 MB
26324              4.38 MB
27996              4.11 MB
28584              6.55 MB

I forgot to mention that the process is using 8,102,640 K of committed memory.

(In reply to Xoirer from comment #16)
Thanks for the memory report. In this one the WebExtensions process has 3,621 zones. This is clearly some kind of leak.

I'm going to move this to the WebExtensions component to investigate. I've filed bug 2058828 to investigate reducing buffer allocator fragmentation.

Component: JavaScript: GC → General
Product: Core → WebExtensions
Summary: SpiderMonkey BufferAllocator free regions remain charged as private commit after Minimize memory usage → WebExtension process ends up with 3,621 zones in normal use

The product::component has been changed since the backlog priority was decided, so we're resetting it.
For more information, please visit BugBot documentation.

Priority: P3 → --

js-main-runtime-gc-buffers/.*/free.*:

3672              81.53 MB
4304                   0 B
5480              10.22 MB
6208               2.05 MB
7596               1.52 MB
10508              1.53 MB
10652              4.42 MB
11708              1.90 MB
12780              2.90 MB
13384             44.17 MB
13984            931.19 KB
14492              4.57 MB
14580              6.21 GB // Extension Process
16824              1.38 MB
16900              2.94 MB
17112            200.24 MB
17332                  0 B
17544              1.54 MB
17664             17.53 MB
18892             17.73 MB
20552             10.93 MB
20680            931.19 KB
20988                  0 B
23432             13.57 MB
24348              9.68 MB
24820              6.89 MB
25332              4.78 MB
25416             38.57 MB
26820              2.53 MB
27240             11.76 MB
27900             24.86 MB
27996             10.84 MB
30044             21.72 MB
30548              9.96 MB
31124              9.63 MB
31340              2.06 MB
32196              3.02 MB
32912             13.27 MB
33444              1.51 MB
33472              1.23 MB
33612            931.19 KB

It seems my extension does indeed have a memory leak, which may be causing fragmentation, preventing the memory from being released (it looks like free memory is fluctuating around 50%).

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: