Title: [170973] trunk/Source/WebCore
- Revision
- 170973
- Author
- akl...@apple.com
- Date
- 2014-07-10 13:24:12 -0700 (Thu, 10 Jul 2014)
Log Message
[iOS WebKit2] Some memory pressure relief tweaks.
<https://webkit.org/b/134811>
Split memory pressure relief into critical and non-critical sections.
Non-critical relief is for clearing out things that are really not
essential, e.g unused font data, text measurement caches, etc.
On iOS, only flip the "WebKit is under memory pressure" flag when we
are under *critical* memroy pressure, rather than doing it early on
and gimping ourselves because other processes are too big.
Also added logging for when we transition in/out of system pressure.
Reviewed by Geoffrey Garen.
* platform/MemoryPressureHandler.cpp:
(WebCore::MemoryPressureHandler::releaseNoncriticalMemory):
(WebCore::MemoryPressureHandler::releaseCriticalMemory):
(WebCore::MemoryPressureHandler::releaseMemory):
* platform/MemoryPressureHandler.h:
(WebCore::MemoryPressureHandler::ReliefLogger::loggingEnabled):
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::install):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (170972 => 170973)
--- trunk/Source/WebCore/ChangeLog 2014-07-10 20:04:42 UTC (rev 170972)
+++ trunk/Source/WebCore/ChangeLog 2014-07-10 20:24:12 UTC (rev 170973)
@@ -1,3 +1,29 @@
+2014-07-10 Andreas Kling <akl...@apple.com>
+
+ [iOS WebKit2] Some memory pressure relief tweaks.
+ <https://webkit.org/b/134811>
+
+ Split memory pressure relief into critical and non-critical sections.
+ Non-critical relief is for clearing out things that are really not
+ essential, e.g unused font data, text measurement caches, etc.
+
+ On iOS, only flip the "WebKit is under memory pressure" flag when we
+ are under *critical* memroy pressure, rather than doing it early on
+ and gimping ourselves because other processes are too big.
+
+ Also added logging for when we transition in/out of system pressure.
+
+ Reviewed by Geoffrey Garen.
+
+ * platform/MemoryPressureHandler.cpp:
+ (WebCore::MemoryPressureHandler::releaseNoncriticalMemory):
+ (WebCore::MemoryPressureHandler::releaseCriticalMemory):
+ (WebCore::MemoryPressureHandler::releaseMemory):
+ * platform/MemoryPressureHandler.h:
+ (WebCore::MemoryPressureHandler::ReliefLogger::loggingEnabled):
+ * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+ (WebCore::MemoryPressureHandler::install):
+
2014-07-10 Beth Dakin <bda...@apple.com>
Need Setting/WKPreference that allows clients to prevent scrollbars from drawing
Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (170972 => 170973)
--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp 2014-07-10 20:04:42 UTC (rev 170972)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp 2014-07-10 20:24:12 UTC (rev 170973)
@@ -68,9 +68,33 @@
{
}
-void MemoryPressureHandler::releaseMemory(bool critical)
+void MemoryPressureHandler::releaseNoncriticalMemory()
{
{
+ ReliefLogger log("Purge inactive FontData");
+ fontCache().purgeInactiveFontData();
+ }
+
+ {
+ ReliefLogger log("Clear WidthCaches");
+ clearWidthCaches();
+ }
+
+ {
+ ReliefLogger log("Discard Selector Query Cache");
+ for (auto* document : Document::allDocuments())
+ document->clearSelectorQueryCache();
+ }
+
+ {
+ ReliefLogger log("Clearing JS string cache");
+ JSDOMWindow::commonVM().stringCache.clear();
+ }
+}
+
+void MemoryPressureHandler::releaseCriticalMemory()
+{
+ {
ReliefLogger log("Empty the PageCache");
int savedPageCacheCapacity = pageCache()->capacity();
pageCache()->setCapacity(0);
@@ -78,11 +102,6 @@
}
{
- ReliefLogger log("Purge inactive FontData");
- fontCache().purgeInactiveFontData();
- }
-
- {
ReliefLogger log("Prune MemoryCache");
memoryCache()->pruneToPercentage(0);
}
@@ -93,32 +112,24 @@
}
{
- ReliefLogger log("Clear WidthCaches");
- clearWidthCaches();
- }
-
- {
ReliefLogger log("Discard StyleResolvers");
for (auto* document : Document::allDocuments())
document->clearStyleResolver();
}
{
- ReliefLogger log("Discard Selector Query Cache");
- for (auto* document : Document::allDocuments())
- document->clearSelectorQueryCache();
- }
-
- {
ReliefLogger log("Discard all JIT-compiled code");
gcController().discardAllCompiledCode();
}
+}
- {
- ReliefLogger log("Clearing JS string cache");
- JSDOMWindow::commonVM().stringCache.clear();
- }
+void MemoryPressureHandler::releaseMemory(bool critical)
+{
+ releaseNoncriticalMemory();
+ if (critical)
+ releaseCriticalMemory();
+
platformReleaseMemory(critical);
{
Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (170972 => 170973)
--- trunk/Source/WebCore/platform/MemoryPressureHandler.h 2014-07-10 20:04:42 UTC (rev 170972)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h 2014-07-10 20:24:12 UTC (rev 170973)
@@ -87,6 +87,7 @@
const char* logString() const { return m_logString; }
static void setLoggingEnabled(bool enabled) { s_loggingEnabled = enabled; }
+ static bool loggingEnabled() { return s_loggingEnabled; }
private:
size_t platformMemoryUsage();
@@ -101,6 +102,9 @@
static void releaseMemory(bool critical);
private:
+ static void releaseNoncriticalMemory();
+ static void releaseCriticalMemory();
+
void uninstall();
void holdOff(unsigned);
Modified: trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm (170972 => 170973)
--- trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm 2014-07-10 20:04:42 UTC (rev 170972)
+++ trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm 2014-07-10 20:24:12 UTC (rev 170973)
@@ -96,11 +96,16 @@
#if PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 80000
unsigned long status = dispatch_source_get_data(_cache_event_source);
critical = status == DISPATCH_MEMORYPRESSURE_CRITICAL;
+ bool wasCritical = memoryPressureHandler().isUnderMemoryPressure();
+ memoryPressureHandler().setUnderMemoryPressure(critical);
if (status == DISPATCH_MEMORYSTATUS_PRESSURE_NORMAL) {
- memoryPressureHandler().setUnderMemoryPressure(false);
+ if (ReliefLogger::loggingEnabled())
+ NSLog(@"System is no longer under (%s) memory pressure.", wasCritical ? "critical" : "non-critical");
return;
}
- memoryPressureHandler().setUnderMemoryPressure(true);
+
+ if (ReliefLogger::loggingEnabled())
+ NSLog(@"Got memory pressure notification (%s)", critical ? "critical" : "non-critical");
#endif
memoryPressureHandler().respondToMemoryPressure(critical);
});
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes