Title: [294181] trunk/Source/WTF
Revision
294181
Author
n...@apple.com
Date
2022-05-13 15:56:17 -0700 (Fri, 13 May 2022)

Log Message

Enforce foreground WebContent memory limit on macOS
https://bugs.webkit.org/show_bug.cgi?id=240397

Reviewed by Chris Dumez.

We removed the foreground memory limit for WebContent on macOS in r272046. But based on some
bug reports that we've seen, it seems like we need to restore some limit to prevent bad user
outcomes when a misbehaving process has runaway memory usage.

This patch adds a foreground memory limit of 8GB or 16GB depending on RAM size. This matches
the limits set by other browsers for their content process.

* wtf/MemoryPressureHandler.cpp:
(WTF::thresholdForMemoryKillOfActiveProcess):
(WTF::MemoryPressureHandler::thresholdForMemoryKill):

Canonical link: https://commits.webkit.org/250548@main

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (294180 => 294181)


--- trunk/Source/WTF/ChangeLog	2022-05-13 22:28:16 UTC (rev 294180)
+++ trunk/Source/WTF/ChangeLog	2022-05-13 22:56:17 UTC (rev 294181)
@@ -53,6 +53,24 @@
 
         * wtf/cocoa/RuntimeApplicationChecksCocoa.h:
 
+2022-05-13  Ben Nham  <n...@apple.com>
+
+        Enforce foreground WebContent memory limit on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=240397
+
+        Reviewed by Chris Dumez.
+
+        We removed the foreground memory limit for WebContent on macOS in r272046. But based on some
+        bug reports that we've seen, it seems like we need to restore some limit to prevent bad user
+        outcomes when a misbehaving process has runaway memory usage.
+
+        This patch adds a foreground memory limit of 8GB or 16GB depending on RAM size. This matches
+        the limits set by other browsers for their content process.
+
+        * wtf/MemoryPressureHandler.cpp:
+        (WTF::thresholdForMemoryKillOfActiveProcess):
+        (WTF::MemoryPressureHandler::thresholdForMemoryKill):
+
 2022-05-10  Brent Fulgham  <bfulg...@apple.com>
 
         Remove abandoned CSSDeferredParser implementation and feature flag

Modified: trunk/Source/WTF/wtf/MemoryPressureHandler.cpp (294180 => 294181)


--- trunk/Source/WTF/wtf/MemoryPressureHandler.cpp	2022-05-13 22:28:16 UTC (rev 294180)
+++ trunk/Source/WTF/wtf/MemoryPressureHandler.cpp	2022-05-13 22:56:17 UTC (rev 294181)
@@ -95,6 +95,12 @@
 }
 #endif
 
+static size_t thresholdForMemoryKillOfActiveProcess(unsigned tabCount)
+{
+    size_t baseThreshold = ramSize() > 16 * GB ? 15 * GB : 7 * GB;
+    return baseThreshold + tabCount * GB;
+}
+
 static size_t thresholdForMemoryKillOfInactiveProcess(unsigned tabCount)
 {
 #if CPU(X86_64) || CPU(ARM64)
@@ -121,7 +127,7 @@
     case WebsamProcessState::Inactive:
         return thresholdForMemoryKillOfInactiveProcess(m_pageCount);
     case WebsamProcessState::Active:
-        break;
+        return thresholdForMemoryKillOfActiveProcess(m_pageCount);
     }
     return std::nullopt;
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to