TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Improving Firefox stability on Windows by retrying failed memory allocation

562 pointsby TangerineDreamover 2 years ago

28 comments

hawskiover 2 years ago
For a few months now I saw a huge improvement on Linux regarding the memory management of Firefox. Previously I had to run Firefox in a separate cgroup to limit its memory usage, because it could easily deplete my whole RAM. And if I did close most of my tabs it did not release the memory back to the system. Now I never actually get to the limit I've set before and also with Auto Tab Discard extension it is well managed. So kudos to the team for such improvements.
评论 #33708364 未加载
评论 #33707053 未加载
评论 #33722360 未加载
评论 #33706809 未加载
评论 #33713140 未加载
st3fanover 2 years ago
Firefox stability is funny ... I was at Mozilla for 10+ years and used Nightly as my daily driver on my work Mac. I don't think I got more than one or two dozen crashes in total. A crash was a special occasion and I would walk to someone's desk to show an explore. It barely every happened. On Nightly. So much love for all the stability work that is happening.
评论 #33724263 未加载
评论 #33708193 未加载
评论 #33708073 未加载
评论 #33712434 未加载
评论 #33715863 未加载
josefrescoover 2 years ago
I can't remember the last time Firefox crashed and I've used it daily on Windows since ... the beginning. Are most issues related to stability more common to Linux/MacOS?
评论 #33708504 未加载
评论 #33708939 未加载
评论 #33707575 未加载
评论 #33707321 未加载
评论 #33707618 未加载
评论 #33710926 未加载
评论 #33712336 未加载
jefftkover 2 years ago
Great work!<p>This is also a good example of the benefit of telemetry: that they have crash numbers coming back from the field lets them tell that this really did work in practice and get a sense of how much of the problem they&#x27;ve solved.
评论 #33707561 未加载
评论 #33707751 未加载
评论 #33706908 未加载
评论 #33708056 未加载
评论 #33708291 未加载
评论 #33706923 未加载
评论 #33708763 未加载
评论 #33707056 未加载
moffkalastover 2 years ago
&gt; with this one weird trick<p>Chromium developers hate him!
ravenstineover 2 years ago
The author left off the part where it was invented by a mother and how dentists hate it! &#x2F;s<p>I suppose it <i>technically</i> improves stability, but the cause seems like a flaw in the Windows operating system, if I&#x27;m understanding correctly.<p>&gt; Stalling the main process led to a smaller increase in tab crashes – which are also unpleasant for the user even if not nearly as annoying as a full browser crash – so we’re cutting those down too.<p>I wonder if this has anything to do with my recent experience with Firefox Nightly on macOS. In the last few weeks I started to experience spontaneous tab crashes that couldn&#x27;t be explained by anything from what I could tell. I could open a new tab with the exact same page and it would manage to not crash. Then I noticed Firefox would sometimes prevent me from viewing tabs <i>until</i> I restarted to update the software. Haven&#x27;t seen it in the last few days, but it was incredibly frustrating. IMO, Firefox should make a best effort to render a page and not have its core functionality stop working entirely until updating.
评论 #33707247 未加载
评论 #33706655 未加载
评论 #33706821 未加载
评论 #33707261 未加载
评论 #33706723 未加载
smodoover 2 years ago
I&#x27;ve been a linux&#x2F;osx user for 20+ years so I&#x27;m not familiar with Windows memory management. It&#x27;d be interesting to know why MS chose this approach and if it has any benefits? Why not just let userspace request whatever it wants?
评论 #33706522 未加载
评论 #33707522 未加载
评论 #33706878 未加载
评论 #33715005 未加载
anonymousabover 2 years ago
For me, there&#x27;s been some kind of weird instability or resource leak that resulted in Windows Firefox getting slower all around and less stable the longer the application is running. It&#x27;s been around and 100% reproducible (over an active session of a few days) for a couple of years.<p>The general problem used to feature some sort of bug where some window processes would completely fail to render&#x2F;paint UI components - instead, rendering them as pure black. The rendering problem is gone, same with a correlated memory leak, but the complete performance slowdown that accompanied it is still there.<p>One day I&#x27;ll submit a bug report or profiler trace or something, but I find it odd every time I see a post about stability or performance fix, it never happens to be the big one that I run into, regardless of the window device or extensions.<p>It makes me wonder if some users just have browsing habits that most others don&#x27;t, so they hit obscure bugs more frequently. But since everyone has their own obscure habits, and thus bugs, there&#x27;s a theoretical endless deluge of problems with no critical mass to justify prioritization or investigation.
评论 #33710633 未加载
LoganDarkover 2 years ago
Has Firefox stopped allocating so much RAM that it fills up all my 40GB? Overcommit isn&#x27;t always enabled, because I&#x27;m not making a 64GB page file just to keep Firefox running for more than a week. (That is how large Windows tried to make it before I disabled the page file.)<p>On my computer, Firefox running out of memory is its own damn fault. Retrying memory allocation won&#x27;t fix anything! And running out of commit space crashes everything else too, so Firefox letting <i>itself</i> crash isn&#x27;t going to help, because it still brings down half the system. (And it still, already crashes when it runs out of memory.)
the8472over 2 years ago
Afaik memory-mapped files don&#x27;t count towards the commit limit. Couldn&#x27;t they roll a custom file-backed allocator (essentially manual swap) to get around the windows limit?
评论 #33707717 未加载
评论 #33708185 未加载
评论 #33708397 未加载
评论 #33706966 未加载
评论 #33709072 未加载
评论 #33706854 未加载
WalterBrightover 2 years ago
This is why I come to read HN.
make3over 2 years ago
I use firefox mobile and it has very strange behavior quite often. It&#x27;s the only browser I would ever use because of the ad block. But sometimes tabs become blacked out and you can&#x27;t refresh them, you have to close them and start new ones. And sometimes I have two different (consecutive?) youtube tabs, and the second tab basically fuses with the first tab, to where both tabs show the same content and the same video. I wonder if in both of these cases a tab process was killed. It&#x27;s pretty common
nurettinover 2 years ago
Haha I put sleep-retry to every explicit memory allocation in every delphi program I wrote since windows xp and not one person acknowledged it as a good practice. This is just too good.
ecef9-8c0f-4374over 2 years ago
Every couple of weeks my firefox was crashing tabs one after another. And I always had to restart firefox. This weird trick fixed it. I made the entire firefox directory readonly.
brailsafeover 2 years ago
Firefox for macOS has been great for me, but Firefox for Android has been brutally unstable, crashing at least a few times per day.
评论 #33708994 未加载
评论 #33712296 未加载
butzover 2 years ago
Thank you for providing more stable experience. Would be great if something could be done about some Unity web games, that sometimes crash whole browser. It is a bit peculiar, while each tab seemingly runs in separate process, but one website crash takes down whole browser.
zmk5over 2 years ago
All these hacks blog posts are really interesting insights by Firefox engineers. Browsers in general are such a complicated system, so it&#x27;s pretty remarkable what they come up with and what they learn when attempting to update Firefox.
tabtabover 2 years ago
Sounds like this feature should be built into the Windows releases of Firefox. Are there downsides?<p>I almost never had Firefox crash for more than a decade of heavy usage, then starting roughly 2 years ago it got janky quite often. Something changed.
errantmindover 2 years ago
Only somewhat related but what I&#x27;d really like to see is an investigation as to why Firefox takes so long to acquire a connection on Linux.<p>I suppose it could be something particular to my setup but it is very slow in comparison to &#x27;ungoogled-chromium&#x27; which I keep around as a second browser.<p>On the network tab I routinely find Firefox in a &#x27;blocked&#x27; state for 100ms. On chrome this rarely exceeds 1ms. I&#x27;ve tried messing around with various configuration options and haven&#x27;t found an answer. The end result is Chrome feeling much snappier.
iamchpover 2 years ago
Awesome to read about the memory management in Windows. (To me Windows seems to much of a black-box, but this is also because I only develop on Linux)
dunno7456over 2 years ago
Does the issue with giant vsize+wasm-guard-pages (from about:memory) when using uBlock origin causing this behavior of OOM Killer?
4ensicover 2 years ago
TL;DR. The latest version (105) of FireFox implemented the trick. Users don&#x27;t need to do anything other than update.
评论 #33706324 未加载
评论 #33706699 未加载
habiburover 2 years ago
I assumed while(!ptr) ptr=malloc(size) had been the norm for applications for the last 10 years.
评论 #33715624 未加载
nottorpover 2 years ago
&gt; The first computer I owned shipped with 128 KiB of RAM and to this day I’m still jarred by the idea that applications can run out of memory given that even 15-year-old machines often shipped with 4 GiB of memory.<p>I think a safe number for the modern web is like 64 Gb. At least if you want to have anything productive open besides the browser...
skozharinovover 2 years ago
&gt; trimming down Firefox memory consumption<p>Of that Firefox that can fill 16 Gb zram with lz4 compression and all remaining physical RAM with less than 100 tabs loaded?
评论 #33706701 未加载
评论 #33706987 未加载
评论 #33709286 未加载
评论 #33707055 未加载
avianover 2 years ago
Click bait title. On Windows, if they get an error on memory allocation, they wait a bit and try again. This gives the OS time to resize the swap file which means that the second try often succeeds.
评论 #33706467 未加载
评论 #33711299 未加载
评论 #33706437 未加载
评论 #33706451 未加载
评论 #33706806 未加载
评论 #33708292 未加载
adqlover 2 years ago
&gt; but what if we could recover from this situation instead? Windows automatically resizes the swap file when it’s almost full, increasing the amount of commit space available. Could we use this to our advantage?<p>I expect followup by some annoyed blogger that notices swap file ate his system partition and he spent whole day debugging the reason of that...
评论 #33708053 未加载
hinkleyover 2 years ago
I’m really not comfortable with people trying to normalize that headline style.<p>This doesn’t work the way adopting kids’ slang “ruins” it and gets them to stop using it. Nobody doing it is worried about looking cool.
评论 #33707531 未加载
评论 #33708065 未加载
评论 #33707125 未加载