Unreviewed, rolling out r234489.
[WebKit-https.git] / Source / WTF / wtf / MemoryPressureHandler.cpp
index 8328853..0f4fd09 100644 (file)
@@ -113,12 +113,22 @@ size_t MemoryPressureHandler::thresholdForMemoryKill()
 static size_t thresholdForPolicy(MemoryUsagePolicy policy)
 {
     const size_t baseThresholdForPolicy = std::min(3 * GB, ramSize());
+
+#if PLATFORM(IOS)
+    const double conservativeThresholdFraction = 0.5;
+    const double strictThresholdFraction = 0.65;
+#else
+    const double conservativeThresholdFraction = 0.33;
+    const double strictThresholdFraction = 0.5;
+#endif
+
     switch (policy) {
+    case MemoryUsagePolicy::Unrestricted:
+        return 0;
     case MemoryUsagePolicy::Conservative:
-        return baseThresholdForPolicy / 3;
+        return baseThresholdForPolicy * conservativeThresholdFraction;
     case MemoryUsagePolicy::Strict:
-        return baseThresholdForPolicy / 2;
-    case MemoryUsagePolicy::Unrestricted:
+        return baseThresholdForPolicy * strictThresholdFraction;
     default:
         ASSERT_NOT_REACHED();
         return 0;
@@ -134,6 +144,11 @@ static MemoryUsagePolicy policyForFootprint(size_t footprint)
     return MemoryUsagePolicy::Unrestricted;
 }
 
+MemoryUsagePolicy MemoryPressureHandler::currentMemoryUsagePolicy()
+{
+    return policyForFootprint(memoryFootprint().value_or(0));
+}
+
 void MemoryPressureHandler::shrinkOrDie()
 {
     RELEASE_LOG(MemoryPressure, "Process is above the memory kill threshold. Trying to shrink down.");
@@ -286,7 +301,6 @@ void MemoryPressureHandler::ReliefLogger::logMemoryUsageChange()
 #if !PLATFORM(COCOA) && !OS(LINUX) && !OS(WINDOWS)
 void MemoryPressureHandler::install() { }
 void MemoryPressureHandler::uninstall() { }
-void MemoryPressureHandler::holdOff(Seconds) { }
 void MemoryPressureHandler::respondToMemoryPressure(Critical, Synchronous) { }
 void MemoryPressureHandler::platformReleaseMemory(Critical) { }
 std::optional<MemoryPressureHandler::ReliefLogger::MemoryUsage> MemoryPressureHandler::ReliefLogger::platformMemoryUsage() { return std::nullopt; }