Title: [203149] trunk/Source/WebCore
Revision
203149
Author
[email protected]
Date
2016-07-12 21:05:06 -0700 (Tue, 12 Jul 2016)

Log Message

[Cocoa] Simulated memory warning doesn't trigger libcache purge.
<https://webkit.org/b/159688>

Reviewed by Chris Dumez.

Since simulated memory warnings will have the "is under memory pressure" flag set,
we were skipping the libcache purge call.

Add a separate flag that tracks whether we're under simulated pressure, and always
prod libcache in that case.

* platform/MemoryPressureHandler.h:
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::platformReleaseMemory):
(WebCore::MemoryPressureHandler::install):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (203148 => 203149)


--- trunk/Source/WebCore/ChangeLog	2016-07-13 03:30:00 UTC (rev 203148)
+++ trunk/Source/WebCore/ChangeLog	2016-07-13 04:05:06 UTC (rev 203149)
@@ -1,3 +1,21 @@
+2016-07-12  Andreas Kling  <[email protected]>
+
+        [Cocoa] Simulated memory warning doesn't trigger libcache purge.
+        <https://webkit.org/b/159688>
+
+        Reviewed by Chris Dumez.
+
+        Since simulated memory warnings will have the "is under memory pressure" flag set,
+        we were skipping the libcache purge call.
+
+        Add a separate flag that tracks whether we're under simulated pressure, and always
+        prod libcache in that case.
+
+        * platform/MemoryPressureHandler.h:
+        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WebCore::MemoryPressureHandler::platformReleaseMemory):
+        (WebCore::MemoryPressureHandler::install):
+
 2016-07-12  Gyuyoung Kim  <[email protected]>
 
         Purge PassRefPtr in Modules/webdatabase

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (203148 => 203149)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.h	2016-07-13 03:30:00 UTC (rev 203148)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h	2016-07-13 04:05:06 UTC (rev 203149)
@@ -143,6 +143,7 @@
     LowMemoryHandler m_lowMemoryHandler;
 
     std::atomic<bool> m_underMemoryPressure;
+    bool m_isSimulatedMemoryPressure { false };
 
 #if PLATFORM(IOS)
     uint32_t m_memoryPressureReason;

Modified: trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm (203148 => 203149)


--- trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm	2016-07-13 03:30:00 UTC (rev 203148)
+++ trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm	2016-07-13 04:05:06 UTC (rev 203149)
@@ -79,7 +79,7 @@
     }
 #endif
 
-    if (critical == Critical::Yes && !isUnderMemoryPressure()) {
+    if (critical == Critical::Yes && (!isUnderMemoryPressure() || m_isSimulatedMemoryPressure)) {
         // libcache listens to OS memory notifications, but for process suspension
         // or memory pressure simulation, we need to prod it manually:
         ReliefLogger log("Purging libcache caches");
@@ -139,6 +139,8 @@
 
     // Allow simulation of memory pressure with "notifyutil -p org.WebKit.lowMemory"
     notify_register_dispatch("org.WebKit.lowMemory", &_notifyToken, dispatch_get_main_queue(), ^(int) {
+        m_isSimulatedMemoryPressure = true;
+
 #if ENABLE(FMW_FOOTPRINT_COMPARISON)
         auto footprintBefore = pagesPerVMTag();
 #endif
@@ -160,6 +162,7 @@
         // Since this is a simulation, unset the "under memory pressure" flag on next runloop.
         dispatch_async(dispatch_get_main_queue(), ^{
             MemoryPressureHandler::singleton().setUnderMemoryPressure(wasUnderMemoryPressure);
+            m_isSimulatedMemoryPressure = false;
         });
     });
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to