Closed Bug 1715761 Opened 3 years ago Closed 2 years ago

High memory usage in SessionWorker.js when restoring hundreds of tabs

Categories

(Firefox :: Session Restore, defect)

Firefox 88
defect

Tracking

()

RESOLVED WORKSFORME
Performance Impact medium

People

(Reporter: boporix989, Unassigned)

Details

(Keywords: perf:resource-use)

Attachments

(1 file)

Attached file memory-report.json.gz

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0

Steps to reproduce:

I batch opened ~700 tabs using Load Background Tabs Lazily and Auto Tab Discard addons, slowly, with almost no load on the system, having tabs automatically discarded a minute after being loaded and loading a new one every 10sec.

Actual results:

On the last ~100 tabs and after the loading was finished, I noticed a memory leak of ~1GB being dropped for 3-5sec every ~30sec. I restarted firefox, the leak continued, I rebooted the system, the leak continued, I started in safe mode, the leak continued, I refreshed firefox, and the leak was no more.

Expected results:

There should have been no leak, and even though the issue can be removed by refreshing, it’s a problem since I have to transfer or lose the data from my old profile every time I want to batch open, for example, a larger bookmarks folder. And I will have to do it again in the future, because it’s a part of my work obligations. I’m attaching a memory report during those 3-5sec, this particular time it dropped ~700MB.

Hey Andrew can you help us on this issue?

Flags: needinfo?(continuation)

I'm afraid I don't entirely understand what you are saying. What does "I noticed a memory leak of ~1GB being dropped for 3-5sec every ~30sec." mean? What is dropping? What does "3-5 seconds every 30 seconds" mean? Is the memory report from when you were experiencing the high memory usage or not?

Assuming that the memory report is from when the memory was high, it looks like there's about 740MB of memory being used for SessionWorker.js, mostly in strings. Maybe the large number of tabs being restored is causing session store to do a bunch of work? I'm not sure how long that would be expected to last.

I'm going to change the summary a bit. It sounds like the memory usage is rising, and then falling, so I wouldn't precisely characterize this as a memory leak. It is possible that the heavy memory usage on a worker is straining the system. Our GC heuristics for workers aren't very highly tuned.

Flags: needinfo?(continuation) → needinfo?(boporix989)
Summary: memory leak spike → High memory usage in SessionWorker.js when restoring hundreds of tabs

It means exactly what I wrote. The amount of available RAM is dropping (differently said, is being used up, or however you want to phrase it). "3-5 seconds every 30 seconds" means that ~1GB of my RAM is being used up (for what appears to be an unknown reason) by firefox every 30 seconds, and that "using up" lasts for 3-5 seconds. Yes, the memory report is from when I was experiencing the high memory usage, as can be read in the last sentence of my previous post.

I usually have anywhere from 100 to 300 tabs open (just above 300 currently, of which ~80% are sitting discarded using Auto Tab Discard) and no matter the number, I keep experiencing this issue. The thing I did notice so far though, is that it would use up more than a 1GB (up to 2GB) as the system is running lower on memory, whereas if I just opened a fresh FF session, it would usually take up 500-700MB (I’m running an 8GB RAM system, so this is quite noticeable).

I’d be more than happy to provide further information or help troubleshoot this issue, but reading the last paragraph I didn’t quite understand what the next steps would include or how I can participate in them, since searching for a similar problem hardly gave me anything useful or something I didn’t already attempt as a solution.

Oops, didn’t clear needinfo, my bad, it’s my first bug report on here.

Flags: needinfo?(boporix989)

Setting a component for this issue in order to get the dev team involved.
If you feel it's an incorrect one please feel free to change it to a more appropriate one.

Component: Untriaged → Performance
Product: Firefox → Core

Completely forgot to update my post here, but I managed to figure out in the meantime that the thing causing the RAM usage was that >500 tabs session I closed out, stored in the "Recently Closed Windows" section. As soon as I remove it from there by closing random firefox windows, or decreasing the number of stored closed windows entries, the problem disappears. I tested it multiple times and found that, as expected, the more tabs I open, the higher the usage after closing those tabs' window. Also it coincides with my previous findings, considering no other measure but refreshing the firefox profile removes the closed windows sessions.

After this finding I can now easily work around this bug. Sure, it would be nice to have it fixed, but do so regarding your own priorities for as far as I’m concerned this can be closed.

Status: UNCONFIRMED → NEW
Component: Performance → Session Restore
Ever confirmed: true
OS: Unspecified → All
Product: Core → Firefox
Hardware: Unspecified → All
Whiteboard: [qf:p2:resource]
Performance Impact: --- → P2
Whiteboard: [qf:p2:resource]

We got rid of SessionWorker! :-)

Do let us know if you're still seeing similar issues (probably as a new bug).

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: