Title: [218776] trunk/Source/WTF
Revision
218776
Author
[email protected]
Date
2017-06-23 17:03:38 -0700 (Fri, 23 Jun 2017)

Log Message

Add notifyutil registrations for going in and out of simulated low memory state
https://bugs.webkit.org/show_bug.cgi?id=173797

Reviewed by Andreas Kling.

Add

notifyutil -p org.WebKit.lowMemory.begin
notifyutil -p org.WebKit.lowMemory.end

for debugging.

* wtf/cocoa/MemoryPressureHandlerCocoa.mm:
(WTF::MemoryPressureHandler::install):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (218775 => 218776)


--- trunk/Source/WTF/ChangeLog	2017-06-23 23:24:11 UTC (rev 218775)
+++ trunk/Source/WTF/ChangeLog	2017-06-24 00:03:38 UTC (rev 218776)
@@ -1,3 +1,20 @@
+2017-06-23  Antti Koivisto  <[email protected]>
+
+        Add notifyutil registrations for going in and out of simulated low memory state
+        https://bugs.webkit.org/show_bug.cgi?id=173797
+
+        Reviewed by Andreas Kling.
+
+        Add
+
+        notifyutil -p org.WebKit.lowMemory.begin
+        notifyutil -p org.WebKit.lowMemory.end
+
+        for debugging.
+
+        * wtf/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WTF::MemoryPressureHandler::install):
+
 2017-06-23  Konstantin Tokarev  <[email protected]>
 
         Remove more unused headers from WTF

Modified: trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm (218775 => 218776)


--- trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm	2017-06-23 23:24:11 UTC (rev 218775)
+++ trunk/Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm	2017-06-24 00:03:38 UTC (rev 218776)
@@ -49,7 +49,7 @@
 
 static dispatch_source_t _cache_event_source = 0;
 static dispatch_source_t _timer_event_source = 0;
-static int _notifyToken;
+static int _notifyTokens[3];
 
 // Disable memory event reception for a minimum of s_minimumHoldOffTime
 // seconds after receiving an event. Don't let events fire any sooner than
@@ -98,7 +98,7 @@
     });
 
     // Allow simulation of memory pressure with "notifyutil -p org.WebKit.lowMemory"
-    notify_register_dispatch("org.WebKit.lowMemory", &_notifyToken, dispatch_get_main_queue(), ^(int) {
+    notify_register_dispatch("org.WebKit.lowMemory", &_notifyTokens[0], dispatch_get_main_queue(), ^(int) {
 #if ENABLE(FMW_FOOTPRINT_COMPARISON)
         auto footprintBefore = pagesPerVMTag();
 #endif
@@ -117,6 +117,13 @@
         });
     });
 
+    notify_register_dispatch("org.WebKit.lowMemory.begin", &_notifyTokens[1], dispatch_get_main_queue(), ^(int) {
+        beginSimulatedMemoryPressure();
+    });
+    notify_register_dispatch("org.WebKit.lowMemory.end", &_notifyTokens[2], dispatch_get_main_queue(), ^(int) {
+        endSimulatedMemoryPressure();
+    });
+
     m_installed = true;
 }
 
@@ -140,8 +147,9 @@
     });
 
     m_installed = false;
-    
-    notify_cancel(_notifyToken);
+
+    for (auto& token : _notifyTokens)
+        notify_cancel(token);
 }
 
 void MemoryPressureHandler::holdOff(unsigned seconds)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to