Title: [180666] trunk/Source/WebCore
Revision
180666
Author
[email protected]
Date
2015-02-26 00:15:04 -0800 (Thu, 26 Feb 2015)

Log Message

[Cocoa] Prod libcache to drop caches in memory pressure relief handler.
<https://webkit.org/b/142024>
<rdar://problem/19966096>

Reviewed by Antti Koivisto.

libcache already listens to the OS memory pressure notifications, but we still
need to manually request a cleanup when doing an iOS process suspension, or when
simulating memory pressure.

* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::platformReleaseMemory): Call out to libcache's
cache_simulate_memory_warning_event() to make sure that nonessential objects
being kept alive by NSCaches get dropped when we need the memory.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (180665 => 180666)


--- trunk/Source/WebCore/ChangeLog	2015-02-26 08:00:36 UTC (rev 180665)
+++ trunk/Source/WebCore/ChangeLog	2015-02-26 08:15:04 UTC (rev 180666)
@@ -1,3 +1,20 @@
+2015-02-26  Andreas Kling  <[email protected]>
+
+        [Cocoa] Prod libcache to drop caches in memory pressure relief handler.
+        <https://webkit.org/b/142024>
+        <rdar://problem/19966096>
+
+        Reviewed by Antti Koivisto.
+
+        libcache already listens to the OS memory pressure notifications, but we still
+        need to manually request a cleanup when doing an iOS process suspension, or when
+        simulating memory pressure.
+
+        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WebCore::MemoryPressureHandler::platformReleaseMemory): Call out to libcache's
+        cache_simulate_memory_warning_event() to make sure that nonessential objects
+        being kept alive by NSCaches get dropped when we need the memory.
+
 2015-02-25  Zalan Bujtas  <[email protected]>
 
         Black line across screen on Adobe Illustrator detail page (non-retina only)

Modified: trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm (180665 => 180666)


--- trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm	2015-02-26 08:00:36 UTC (rev 180665)
+++ trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm	2015-02-26 08:15:04 UTC (rev 180666)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011-2014 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2011-2015 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -44,9 +44,11 @@
 #import "WebCoreThread.h"
 #endif
 
+extern "C" void cache_simulate_memory_warning_event(uint64_t);
+
 namespace WebCore {
 
-void MemoryPressureHandler::platformReleaseMemory(bool)
+void MemoryPressureHandler::platformReleaseMemory(bool critical)
 {
     {
         ReliefLogger log("Drain LayerPools");
@@ -60,6 +62,17 @@
     }
 #endif
 
+#if PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
+    if (critical && !isUnderMemoryPressure()) {
+        // 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");
+        cache_simulate_memory_warning_event(DISPATCH_MEMORYPRESSURE_CRITICAL);
+    }
+#else
+    UNUSED_PARAM(critical);
+#endif
+
 #if PLATFORM(IOS)
     if (isUnderMemoryPressure()) {
         gcController().garbageCollectSoon();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to