Open Bug 1902566 (gfx-mem-leaks) Opened 2 years ago Updated 4 months ago

[meta] Graphics memory leaks (system and/or gpu)

Categories

(Core :: Graphics, task, P2)

task

Tracking

()

People

(Reporter: ahale, Assigned: sotaro)

References

(Depends on 9 open bugs, Blocks 1 open bug)

Details

(Keywords: meta)

This meta bug is for memory leak bugs in the Graphics component, individual bugs can be filed against this but should be moved to one of the category meta bugs that block this meta bug during triage.

User troubleshooting guide for reporting a memory leak bug in this component:

  • Use the browser in a way you are okay with repeating (e.g. open a tab, make a web search of your choice, close the tab), check memory usage (e.g. take a screenshot of Task Manager if on Windows, especially the Performance tab in Task Manager which shows total memory usage and GPU memory usage), do this more than once, take a screenshot again each time. Using an OS-level tool like this shows whether the browser has increased memory usage even if it is not being tracked properly in the about:memory page (for example much of the browser's GPU memory usage is actually attributed to dwm.exe which is the desktop compositor).
    • Note: Continuous memory growth in a single tab without much interaction is also interesting, in which case you would take the screenshots at different times with the tab open.
  • The first screenshot of a memory metric is usually not very useful, compare the second and third (or later) screenshots to see if memory usage has really grown which shows it's likely a memory leak, please report the bug and explain what you were doing that triggered it, so we can look into it.
    • Comparing the first and second screenshot is not very useful because the OS may have cached some files after loading the first time, the second and later screenshots show what repeating the action did.
  • It is very useful to attach to your bug the text from the URL about:support (it has buttons at the top to copy to clipboard, which you can paste in an attachment using Attach New File), this shows what OS version, GPU model and driver version you are using.
  • It is also useful to save a memory report from the URL about:memory (you may wish to check the Anonymize button there) each time you take a screenshot of Task Manager, these reports can be compared (again using about:memory) to see the differences in each part of the browser which makes it quicker to find the issue as we know at least what the browser thinks it is using memory for (GPU memory is not tracked in great detail there however - it is reported as summary values like gpu-dedicated).

Some notes on memory leaks in general:

  • Scrolling on an infinite-scrolling web page may continuously use more memory if the web page is not written well, which is a site issue and not necessarily a memory leak in the browser.
  • Memory leaks occurring from repeated actions are the most interesting and most actionable, it's vitally important to know the repro steps and what OS version and GPU driver version is involved.
  • Memory leaks can also occur within the lifetime of a tab when using an adblocker extension, depending on how the site works, but that is JS memory usage, which is not Graphics related.
Severity: -- → S3
Keywords: meta
Priority: -- → P2
Depends on: 1902569
Depends on: 1798074
Depends on: 1807258
Depends on: 1834979
Depends on: 1858995
Alias: gfx-mem-leaks
Depends on: 1879521
See Also: → 1386177

Prefs that can be useful to diagnose GPU memory usage:

  • Set "webrender.debug.profiler" to true and "webrender.debug.profiler-ui" to "Memory".
  • Set "webrender.debug.texture-cache" to "true" and "webrender.debug.texture-cache.clear-evicted" to true.
Depends on: 1903398
Depends on: 1904174
Blocks: gfx-triage
Depends on: 1906476
No longer blocks: gfx-triage

I have this "GPU process" issue. Youtube, other tabs are closed. Even then GPU process keeps hogging memory for ever...
I put a screenshot on ideas/mozilla..

Flags: needinfo?(bhood)
Depends on: 1962210

You shifted this bug to angle issue and closed the bug Bug 1962210.
I confirm that disabling angle made no difference to GPU process.
Using windows task manager I can clearly see that Edge uses almost half the memory, even lesser, compared to what firefox uses in GPU process.
This is a major issue, don't just sideline it.
Firefox becomes unusable/slow with 4-5 video tabs..

Flags: needinfo?(bhood)

GPU process video memory usage is a real concern and is actively being worked on.

As of this writing, there are two main causes of high video memory usage in Firefox and they are entirely independent problems:

  • Video memory leaks when starting and stopping videos - this is tracked in meta bug https://bugzilla.mozilla.org/show_bug.cgi?id=1902569 - this is the main problem that people are encountering and it is being worked on, it is a genuine memory leak (i.e. if you open a window, play some videos, especially scrolling on YouTube Shorts for example, and then close that window, memory usage is still higher than it was before you opened the window).
    • This problem only appears if you view videos, and does not get better until you restart the browser, showing it is a real memory leak, it is being worked on.
  • WebRender is creating separate textures for each window to display web pages, each window you open has its own set of intermediate rendering textures, this does not leak (i.e. you can open a window and close it and it will have the same video memory usage as before you opened it), but is not as efficient with video memory as one would hope, so there's room for improvement but it rarely directly impacts user experience, importantly it does not get worse over time (and is thus not a memory leak). Any time you see high video memory usage, this is usually not the main cause but a contributor to the problem.
    • This problem gets worse the more windows you have open at a time, and better if you close them, so it affects some usage patterns more than others, it is generally not causing system issues, but it would be nice to improve here. Given that this is not causing system instability and is not a memory leak, it is lower priority.

(In reply to Ashley Hale [:ahale] from comment #4)

GPU process video memory usage is a real concern and is actively being worked on.

As of this writing, there are two main causes of high video memory usage in Firefox and they are entirely independent problems:

  • Video memory leaks when starting and stopping videos - this is tracked in meta bug https://bugzilla.mozilla.org/show_bug.cgi?id=1902569 - this is the main problem that people are encountering and it is being worked on, it is a genuine memory leak (i.e. if you open a window, play some videos, especially scrolling on YouTube Shorts for example, and then close that window, memory usage is still higher than it was before you opened the window).
    • This problem only appears if you view videos, and does not get better until you restart the browser, showing it is a real memory leak, it is being worked on.
  • WebRender is creating separate textures for each window to display web pages, each window you open has its own set of intermediate rendering textures, this does not leak (i.e. you can open a window and close it and it will have the same video memory usage as before you opened it), but is not as efficient with video memory as one would hope, so there's room for improvement but it rarely directly impacts user experience, importantly it does not get worse over time (and is thus not a memory leak). Any time you see high video memory usage, this is usually not the main cause but a contributor to the problem.
    • This problem gets worse the more windows you have open at a time, and better if you close them, so it affects some usage patterns more than others, it is generally not causing system issues, but it would be nice to improve here. Given that this is not causing system instability and is not a memory leak, it is lower priority.

When will this get sorted?

media.cache_size when set to 256000, decreases RAM usage, linked to GPU process. Can you please check this and let me know of any side effects?

Flags: needinfo?(ahale)
Blocks: gfx-triage
Flags: needinfo?(ahale)
Depends on: 1897006
Depends on: 1820789
Depends on: 1968827
Depends on: 1952340
No longer blocks: gfx-triage
Assignee: nobody → sotaro.ikeda.g

(In reply to KRM from comment #6)

media.cache_size when set to 256000, decreases RAM usage, linked to GPU process. Can you please check this and let me know of any side effects?

Any idea if there's some ratio involved with this, like it's some amount per process -- or is it just straight up how much of the GPU process' memory the media cache will use? The default is 512000 kb, presumably kilobytes, which would only be 500 megabytes of the GPU process' memory (if it's just a straight one-to-one value). That might be the straw that broke the camel's back, but it wouldn't be the main culprit, unless there's some ratio involved.

I have rechecked it again. 256000 makes no difference. RAM usage is still high with 2-3 tabs, specially if one is youtube. Better check video codecs.

maybe its related to layers.gpu-process.enabled

KRM, do you happen to have dom.ipc.processPriorityManager.backgroundUsesEcoQoS set to false? I believe having it set to false increases memory usage in Firefox, but I don't believe it's a cause of a true memory leak.

(In reply to mmortal03 from comment #10)

KRM, do you happen to have dom.ipc.processPriorityManager.backgroundUsesEcoQoS set to false? I believe having it set to false increases memory usage in Firefox, but I don't believe it's a cause of a true memory leak.

its set to default - true

Depends on: 1971042

just make "Minimize memory usage" in about:memory do its job after every tab is closed.. or after a set time.

(In reply to KRM from comment #12)

just make "Minimize memory usage" in about:memory do its job after every tab is closed.. or after a set time.

Is that button's function destructive in any way? Does it literally just clear out content of memory that is no longer being used, but that remains cached for whatever reason?

It does clear GPU memory but it goes right back to original if i switch back to youtube tab. btw GPU also shoots up in pinterest/instagram. I had to decrease processcount/webisolated to decrease RAM usage.

(In reply to KRM from comment #14)

It does clear GPU memory but it goes right back to original if i switch back to youtube tab. btw GPU also shoots up in pinterest/instagram. I had to decrease processcount/webisolated to decrease RAM usage.

Yeah, I lowered each of those by 1 from where they were by default.

Maybe we should be commenting at the following bug regarding a YouTube tab increasing GPU memory use but not releasing it after the tab is closed? https://bugzilla.mozilla.org/show_bug.cgi?id=1902569

Did you mention which GPU you are using? I wonder if it's only affecting particular GPUs.

Intel 4400. I put webisolated to 1. processcount to 2. Don't assume its only related to youtube. Every graphic intensive website shoots up RAM usage, with even 3-4 tabs.. Whereas in Edge I can open 15 tabs, with no issues, it puts them to sleep if required.

My main laptop also has a very old integrated Intel GPU, the Intel HD 4000, but I've also got a discrete Nvidia GPU in it, too. It might be something for Firefox devs to explore; these older Intel integrated GPUs versus the discrete ones. It'd be interesting for someone to do some side-by-side comparisons to see if there are any patterns to it.

(In reply to mmortal03 from comment #17)

My main laptop also has a very old integrated Intel GPU, the Intel HD 4000, but I've also got a discrete Nvidia GPU in it, too. It might be something for Firefox devs to explore; these older Intel integrated GPUs versus the discrete ones. It'd be interesting for someone to do some side-by-side comparisons to see if there are any patterns to it.

My Radeon 5700 XT has the same problem. Even without videos, but scrolling, or even idling timeline of Mastodon is eating VRAM alive.

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