Title: [218108] trunk/Source/WebCore
Revision
218108
Author
[email protected]
Date
2017-06-12 10:28:39 -0700 (Mon, 12 Jun 2017)

Log Message

Call _sqlite3_purgeEligiblePagerCacheMemory() on memory pressure only if sqlite is initialized
https://bugs.webkit.org/show_bug.cgi?id=173264

Reviewed by Ryosuke Niwa.

Call _sqlite3_purgeEligiblePagerCacheMemory() on memory pressure only if sqlite is initialized.
Otherwise, not only is it no needed, it is also potentially unsafe.

* page/MemoryRelease.cpp:
(WebCore::registerSQLiteMemoryPressureHandler):
* page/MemoryRelease.h:
* page/cocoa/MemoryReleaseCocoa.mm:
(WebCore::platformReleaseMemory):
(WebCore::registerSQLiteMemoryPressureHandler):
* platform/sql/SQLiteDatabase.cpp:
(WebCore::initializeSQLiteIfNecessary):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (218107 => 218108)


--- trunk/Source/WebCore/ChangeLog	2017-06-12 17:19:22 UTC (rev 218107)
+++ trunk/Source/WebCore/ChangeLog	2017-06-12 17:28:39 UTC (rev 218108)
@@ -1,3 +1,22 @@
+2017-06-12  Chris Dumez  <[email protected]>
+
+        Call _sqlite3_purgeEligiblePagerCacheMemory() on memory pressure only if sqlite is initialized
+        https://bugs.webkit.org/show_bug.cgi?id=173264
+
+        Reviewed by Ryosuke Niwa.
+
+        Call _sqlite3_purgeEligiblePagerCacheMemory() on memory pressure only if sqlite is initialized.
+        Otherwise, not only is it no needed, it is also potentially unsafe.
+
+        * page/MemoryRelease.cpp:
+        (WebCore::registerSQLiteMemoryPressureHandler):
+        * page/MemoryRelease.h:
+        * page/cocoa/MemoryReleaseCocoa.mm:
+        (WebCore::platformReleaseMemory):
+        (WebCore::registerSQLiteMemoryPressureHandler):
+        * platform/sql/SQLiteDatabase.cpp:
+        (WebCore::initializeSQLiteIfNecessary):
+
 2017-06-12  Zan Dobersek  <[email protected]>
 
         [GCrypt] Use utility functions in CryptoKeyEC, CryptoKeyRSA

Modified: trunk/Source/WebCore/page/MemoryRelease.cpp (218107 => 218108)


--- trunk/Source/WebCore/page/MemoryRelease.cpp	2017-06-12 17:19:22 UTC (rev 218107)
+++ trunk/Source/WebCore/page/MemoryRelease.cpp	2017-06-12 17:28:39 UTC (rev 218108)
@@ -190,6 +190,7 @@
 void platformReleaseMemory(Critical) { }
 void jettisonExpensiveObjectsOnTopLevelNavigation() { }
 void registerMemoryReleaseNotifyCallbacks() { }
+void registerSQLiteMemoryPressureHandler() { }
 #endif
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/MemoryRelease.h (218107 => 218108)


--- trunk/Source/WebCore/page/MemoryRelease.h	2017-06-12 17:19:22 UTC (rev 218107)
+++ trunk/Source/WebCore/page/MemoryRelease.h	2017-06-12 17:28:39 UTC (rev 218108)
@@ -34,5 +34,6 @@
 void jettisonExpensiveObjectsOnTopLevelNavigation();
 WEBCORE_EXPORT void registerMemoryReleaseNotifyCallbacks();
 WEBCORE_EXPORT void logMemoryStatisticsAtTimeOfDeath();
+void registerSQLiteMemoryPressureHandler();
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm (218107 => 218108)


--- trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm	2017-06-12 17:19:22 UTC (rev 218107)
+++ trunk/Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm	2017-06-12 17:28:39 UTC (rev 218108)
@@ -40,6 +40,8 @@
 
 extern "C" void _sqlite3_purgeEligiblePagerCacheMemory(void);
 
+static bool isSQLiteMemoryPressureHandlerRegisted { false };
+
 namespace WebCore {
 
 void platformReleaseMemory(Critical)
@@ -48,7 +50,8 @@
     GSFontPurgeFontCache();
 #endif
 
-    _sqlite3_purgeEligiblePagerCacheMemory();
+    if (isSQLiteMemoryPressureHandlerRegisted)
+        _sqlite3_purgeEligiblePagerCacheMemory();
 
     for (auto& pool : LayerPool::allLayerPools())
         pool->drain();
@@ -100,4 +103,9 @@
     });
 }
 
+void registerSQLiteMemoryPressureHandler()
+{
+    isSQLiteMemoryPressureHandlerRegisted = true;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp (218107 => 218108)


--- trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2017-06-12 17:19:22 UTC (rev 218107)
+++ trunk/Source/WebCore/platform/sql/SQLiteDatabase.cpp	2017-06-12 17:28:39 UTC (rev 218108)
@@ -29,6 +29,7 @@
 
 #include "DatabaseAuthorizer.h"
 #include "Logging.h"
+#include "MemoryRelease.h"
 #include "SQLiteFileSystem.h"
 #include "SQLiteStatement.h"
 #include <mutex>
@@ -66,6 +67,7 @@
 #endif
             CRASH();
         }
+        registerSQLiteMemoryPressureHandler();
     });
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to