Firefox GPU RAM leak
Update: upgrading from Windows 10 version 1903 to 2004 solved this problem. It looked like 2004 solved the problem, and it might have helped, but my computer just barfed again with Firefox holding on to 25GB of VRAM. And with only like 6 tabs open.
Update 4: after several more months I can say Windows 10 2004 didn’t help anything. The really maddening thing is I have two nearly identical systems (same hardware, slightly different software install history). The problem occurs on one and not the other.
I’m chasing down a problem on my Windows system. Every few days it crashes, the GPU acts like its out of memory. I have a fancy 1080 Ti graphics card with 8GB of video RAM and don’t run things long term that use VRAM, so what’s the problem?
Firefox.
First trick was finding out what system processes were using video RAM. Process Explorer won’t show you. But the built-in task manager will. The “Performance” tab gives you a graph of GPU memory usage over time. And the “Details” tab will show you per-process if you add the display columns “Dedicated GPU Memory” and “Shared GPU Memory”.
When first launched Firefox allocates about 100MB of Dedicated GPU RAM. Then as I watched during the day it climbed; 2GB, 4GB... Even closing all tabs but one tab open to about:memory (as simple and passive a page as you could imagine) all that RAM was still open. After 24 hours it was 4GB. After 48 hours it was 17GB. (neat trick, since I only have 8GB of actual video RAM. I guess it pages?) Closing Firefox entirely does release the VRAM.
I’m still not sure what’s wrong with Firefox that it’s doing this. There are reports from users of this problem over the years: this bug is the best match, also this bug and that one. Not much resolution there. I also can’t find any tools to figure out what inside Firefox is holding the VRAM. That about:memory page is only for CPU RAM, not VRAM.
The most likely theory I’ve seen there is that hardware accelerated decoding of HTML5 video is the culprit. That the video decoder is somehow not releasing VRAM. FWIW my system has media.hardware-video-decoding.enabled set to true, the default. I think I can sort of reproduce that as a bug by watching Twitch and then closing it repeatedly. But not Youtube. I think a real culprit might be me browsing meme videos on Reddit using the Imagus extension (which opens media in a popup window). Another possibility is Reddit’s previews of RPAN streaming video. But I’ve not been able to reproduce it consistently in a way I understand.
Another theory I had was that it was related to the webrender experimental feature. But I have gfx.webrender.all set to false, so that’s not it. Also the leak seems to be triggered only by some kinds of pages, not all, and my impression is webrender would affect all pages.
One last bit of cargo cult advice gleaned from the Firefox bug reports is that Windows 1903 fix KB4497935 might improve things. Reading the Microsoft notes for that I don’t see how it’s related. But I am running 1903 without that patch. I think that’s the next thing I’ll try; install that patch and see if the problem goes away. (Also why am I not running a newer version of Windows?!)
Update: joke’s on me, I can’t install KB4497935 standalone. Installer refuses to run and says it’s not for my system. Maybe it was superseded by a later patch? In general I keep my systems updated, that seems likely. Anyway I’m going to just jump to Windows 10 version 2004 now, that’ll definitely mix everything up.
Update 2: I ran for a couple of days on 2004 and it definitely fixes the problem. At least, mostly. Firefox regularly returns big chunks if video RAM as soon as I close a tab. More importantly I kept it running for two full days and at the end it had maybe 500MB allocated. A bit more than the 100MB or so it started with, but well below the 8+GB that resulted in system crashes before. I don’t know what in particular fixed it, but something in the transition from Windows 10 1903 to 2004 either fixed or papered over the problem.
Update 3: I swear 2004 has helped. But just now I was playing World of Warcraft (uses 2GB of VRAM) with Firefox in the background with about 8 tabs. And WoW complained it had no RAM and when I checked, Firefox had 25GB of VRAM allocated to it. Quitting Firefox fixed it.
Computers are complicated.