Jettison all StyleResolver data on memory pressure.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Dec 2013 16:50:49 +0000 (16:50 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Dec 2013 16:50:49 +0000 (16:50 +0000)
<https://webkit.org/b/125498>

The StyleResolver can be rebuilt relatively quickly; we already
have an optimization that discards it some time after last use.

If we find ourseles under serious memory pressure, don't wait for
the timer to kick in, throw everything overboard right away.

~5MB progression post-pressure on Membuster3.

Reviewed by Anders Carlsson.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@160370 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/Page.cpp
Source/WebCore/page/Page.h
Source/WebCore/platform/mac/MemoryPressureHandlerMac.mm

index 994c820fe065764f0470ec462ce07b8c4a4d10a0..f86fcb9a0bcae937c29701754f6277681c043021 100644 (file)
@@ -1,3 +1,18 @@
+2013-12-10  Andreas Kling  <akling@apple.com>
+
+        Jettison all StyleResolver data on memory pressure.
+        <https://webkit.org/b/125498>
+
+        The StyleResolver can be rebuilt relatively quickly; we already
+        have an optimization that discards it some time after last use.
+
+        If we find ourseles under serious memory pressure, don't wait for
+        the timer to kick in, throw everything overboard right away.
+
+        ~5MB progression post-pressure on Membuster3.
+
+        Reviewed by Anders Carlsson.
+
 2013-12-10  Martin Robinson  <mrobinson@igalia.com>
 
         [GTK] [CMake] Add support for building the DOM bindings
index ae7203da58241711fd794fbf9fe6fc7e8bc6bcd3..8cf05ddb9897ff16757d053044a4feab63692869 100644 (file)
@@ -487,6 +487,20 @@ void Page::setNeedsRecalcStyleInAllFrames()
     }
 }
 
+void Page::jettisonStyleResolversInAllDocuments()
+{
+    if (!allPages)
+        return;
+
+    for (auto it = allPages->begin(), end = allPages->end(); it != end; ++it) {
+        Page& page = **it;
+        for (Frame* frame = &page.mainFrame(); frame; frame = frame->tree().traverseNext()) {
+            if (Document* document = frame->document())
+                document->clearStyleResolver();
+        }
+    }
+}
+
 void Page::refreshPlugins(bool reload)
 {
     if (!allPages)
index 723437061c55c0e6f88965a9d2df93a04d2050b2..5ff8e27754710b59f0b06d9d165a74ae08631d35 100644 (file)
@@ -111,6 +111,7 @@ class Page : public Supplementable<Page> {
 
 public:
     static void updateStyleForAllPagesAfterGlobalChangeInEnvironment();
+    static void jettisonStyleResolversInAllDocuments();
 
     // It is up to the platform to ensure that non-null clients are provided where required.
     struct PageClients {
index 538a9326e93fba996e7889d86bd4d4befffbf37a..ad85e60197d7bbe8849f4bddf8dae04a2e49dfc3 100644 (file)
@@ -30,6 +30,7 @@
 #import <WebCore/GCController.h>
 #import <WebCore/FontCache.h>
 #import <WebCore/MemoryCache.h>
+#import <WebCore/Page.h>
 #import <WebCore/PageCache.h>
 #import <WebCore/LayerPool.h>
 #import <WebCore/ScrollingThread.h>
@@ -163,6 +164,8 @@ void MemoryPressureHandler::releaseMemory(bool)
 
     clearWidthCaches();
 
+    Page::jettisonStyleResolversInAllDocuments();
+
     gcController().discardAllCompiledCode();
 
     // FastMalloc has lock-free thread specific caches that can only be cleared from the thread itself.