Skip to content
Permalink
Browse files
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
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294181 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
bnham committed May 13, 2022
1 parent a672a4b commit f822d46cdb31d1d3df1915a99c0413acbcb06fd1
Showing with 25 additions and 1 deletion.
  1. +18 −0 Source/WTF/ChangeLog
  2. +7 −1 Source/WTF/wtf/MemoryPressureHandler.cpp
@@ -53,6 +53,24 @@

* wtf/cocoa/RuntimeApplicationChecksCocoa.h:

2022-05-13 Ben Nham <nham@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 <bfulgham@apple.com>

Remove abandoned CSSDeferredParser implementation and feature flag
@@ -95,6 +95,12 @@ static const char* toString(MemoryUsagePolicy policy)
}
#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 @@ std::optional<size_t> MemoryPressureHandler::thresholdForMemoryKill()
case WebsamProcessState::Inactive:
return thresholdForMemoryKillOfInactiveProcess(m_pageCount);
case WebsamProcessState::Active:
break;
return thresholdForMemoryKillOfActiveProcess(m_pageCount);
}
return std::nullopt;
}

0 comments on commit f822d46

Please sign in to comment.