news.volyx.in

Improving Firefox stability on Windows by retrying failed memory allocation (hacks.mozilla.org)

562 points by TangerineDream · 1385 days ago · 324 comments on HN

Article summary

Mozilla implemented a trick in Firefox 105 to improve stability on Windows by retrying failed memory allocations, which led to a 70% reduction in out-of-memory crashes. This trick takes advantage of Windows' behavior of resizing the swap file when it's almost full, allowing the allocation to succeed on the second try. The article explains how Windows handles memory differently than other operating systems, which can lead to applications running out of memory even when there is plenty of physical memory available. This change has significantly improved Firefox's stability on Windows.

Main themes

  • Windows memory management
  • Firefox stability
  • Memory allocation tricks
  • Operating system differences
  • Browser development
  • Clickbait titles
  • Memory management complexities
  • Software stability improvements

What commenters say

  • The trick is clever and effective, but the Windows memory management approach is questionable.
  • Implementing this trick in other applications could also improve their stability.
  • The use of 'this one weird trick' in the title is seen as clickbait, but some argue it's now a cultural joke.
  • Disabling swap in Windows can lead to running out of memory earlier than expected, even with plenty of RAM.
  • Some argue that Microsoft should implement a similar retry mechanism in their malloc function.
  • Others think that the solution is for users to buy more memory or use different applications.
  • The article provides a valuable insight into the complexities of memory management in browsers and operating systems.
  • The 'weird trick' approach may not be suitable for all applications, as it can introduce delays and other issues.