[Chromium] Add memory threshold values to WebKitPlatformSupport.h
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Sep 2011 18:10:26 +0000 (18:10 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 4 Sep 2011 18:10:26 +0000 (18:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=67575

Reviewed by Darin Fisher.

Source/WebCore:

Grab these memory thresholds from PlatformSupport rather than hard-coding them.

* bindings/v8/V8GCController.cpp:
(WebCore::V8GCController::checkMemoryUsage):
* platform/chromium/PlatformSupport.h:
* platform/qt/PlatformSupport.h:
(WebCore::PlatformSupport::lowMemoryUsageMB):
(WebCore::PlatformSupport::highMemoryUsageMB):
(WebCore::PlatformSupport::highUsageDeltaMB):

Source/WebKit/chromium:

Instead of hard-coding these values, we now grab them from
WebKitPlatformSupport because Android wishes to configure them on a
per-device basis.

One could view grabing these values from PlatformSupport as a bit of a
layering violation (because they feel like policy), but another view is
that the alternative implementation is to query the OS for various
memory parameters.  In either case, getting these values via
PlatformSupport is much easier and consistent with the other memory
related queries in PlatformSupport already.

* public/WebKitPlatformSupport.h:
(WebKit::WebKitPlatformSupport::lowMemoryUsageMB):
(WebKit::WebKitPlatformSupport::highMemoryUsageMB):
(WebKit::WebKitPlatformSupport::highUsageDeltaMB):
* src/PlatformSupport.cpp:
(WebCore::PlatformSupport::lowMemoryUsageMB):
(WebCore::PlatformSupport::highMemoryUsageMB):
(WebCore::PlatformSupport::highUsageDeltaMB):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/V8GCController.cpp
Source/WebCore/platform/chromium/PlatformSupport.h
Source/WebCore/platform/qt/PlatformSupport.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/public/WebKitPlatformSupport.h
Source/WebKit/chromium/src/PlatformSupport.cpp

index bc52c9d..7da02a7 100644 (file)
@@ -1,3 +1,20 @@
+2011-09-04  Adam Barth  <abarth@webkit.org>
+
+        [Chromium] Add memory threshold values to WebKitPlatformSupport.h
+        https://bugs.webkit.org/show_bug.cgi?id=67575
+
+        Reviewed by Darin Fisher.
+
+        Grab these memory thresholds from PlatformSupport rather than hard-coding them.
+
+        * bindings/v8/V8GCController.cpp:
+        (WebCore::V8GCController::checkMemoryUsage):
+        * platform/chromium/PlatformSupport.h:
+        * platform/qt/PlatformSupport.h:
+        (WebCore::PlatformSupport::lowMemoryUsageMB):
+        (WebCore::PlatformSupport::highMemoryUsageMB):
+        (WebCore::PlatformSupport::highUsageDeltaMB):
+
 2011-09-04  Kevin Ollivier  <kevino@theolliviers.com>
 
         [wx] Unreviewed build fix. Add new / moved files missing from last commit.
index e9bed09..1005c8c 100644 (file)
@@ -464,16 +464,15 @@ void V8GCController::gcEpilogue()
 void V8GCController::checkMemoryUsage()
 {
 #if PLATFORM(CHROMIUM) || PLATFORM(QT) && !OS(SYMBIAN)
-    // These values are appropriate for Chromium only.
-    const int lowUsageMB = 256;  // If memory usage is below this threshold, do not bother forcing GC.
-    const int highUsageMB = 1024;  // If memory usage is above this threshold, force GC more aggresively.
-    const int highUsageDeltaMB = 128;  // Delta of memory usage growth (vs. last workingSetEstimateMB) to force GC when memory usage is high.
+    const int lowMemoryUsageMB = PlatformSupport::lowMemoryUsageMB();
+    const int highMemoryUsageMB = PlatformSupport::highMemoryUsageMB();
+    const int highUsageDeltaMB = PlatformSupport::highUsageDeltaMB();
 #else
     return;
 #endif
 
     int memoryUsageMB = getMemoryUsageInMB();
-    if ((memoryUsageMB > lowUsageMB && memoryUsageMB > 2 * workingSetEstimateMB) || (memoryUsageMB > highUsageMB && memoryUsageMB > workingSetEstimateMB + highUsageDeltaMB))
+    if ((memoryUsageMB > lowMemoryUsageMB && memoryUsageMB > 2 * workingSetEstimateMB) || (memoryUsageMB > highMemoryUsageMB && memoryUsageMB > workingSetEstimateMB + highUsageDeltaMB))
         v8::V8::LowMemoryNotification();
 }
 
index d757621..78e0174 100644 (file)
@@ -197,9 +197,14 @@ public:
     // Returns the current space allocated for the pagefile, in MB.
     // That is committed size for Windows and virtual memory size for POSIX
     static int memoryUsageMB();
-
     // Same as above, but always returns actual value, without any caches.
     static int actualMemoryUsageMB();
+    // If memory usage is below this threshold, do not bother forcing GC.
+    static int lowMemoryUsageMB();
+    // If memory usage is above this threshold, force GC more aggressively.
+    static int highMemoryUsageMB();
+    // Delta of memory usage growth (vs. last actualMemoryUsageMB()) to force GC when memory usage is high.
+    static int highUsageDeltaMB();
 
     // MimeType -----------------------------------------------------------
     static bool isSupportedImageMIMEType(const String& mimeType);
index 629a4e3..0e188db 100644 (file)
@@ -91,6 +91,15 @@ public:
     static bool popupsAllowed(NPP npp);
     // Plugin
     static NPObject* pluginScriptableObject(Widget*);
+
+    // If memory usage is below this threshold, do not bother forcing GC.
+    static int lowMemoryUsageMB() { return 256; }
+
+    // If memory usage is above this threshold, force GC more aggressively.
+    static int highMemoryUsageMB() { return 1024; }
+
+    // Delta of memory usage growth (vs. last actualMemoryUsageMB()) to force GC when memory usage is high.
+    static int highUsageDeltaMB() { return 128; }
 };
 
 }
index 6caa338..545247b 100644 (file)
@@ -1,3 +1,30 @@
+2011-09-04  Adam Barth  <abarth@webkit.org>
+
+        [Chromium] Add memory threshold values to WebKitPlatformSupport.h
+        https://bugs.webkit.org/show_bug.cgi?id=67575
+
+        Reviewed by Darin Fisher.
+
+        Instead of hard-coding these values, we now grab them from
+        WebKitPlatformSupport because Android wishes to configure them on a
+        per-device basis.
+
+        One could view grabing these values from PlatformSupport as a bit of a
+        layering violation (because they feel like policy), but another view is
+        that the alternative implementation is to query the OS for various
+        memory parameters.  In either case, getting these values via
+        PlatformSupport is much easier and consistent with the other memory
+        related queries in PlatformSupport already.
+
+        * public/WebKitPlatformSupport.h:
+        (WebKit::WebKitPlatformSupport::lowMemoryUsageMB):
+        (WebKit::WebKitPlatformSupport::highMemoryUsageMB):
+        (WebKit::WebKitPlatformSupport::highUsageDeltaMB):
+        * src/PlatformSupport.cpp:
+        (WebCore::PlatformSupport::lowMemoryUsageMB):
+        (WebCore::PlatformSupport::highMemoryUsageMB):
+        (WebCore::PlatformSupport::highUsageDeltaMB):
+
 2011-09-02  Adam Barth  <abarth@webkit.org>
 
         Remove WebKitClient.h
index a692117..7e47164 100644 (file)
@@ -171,6 +171,15 @@ public:
     // Same as above, but always returns actual value, without any caches.
     virtual size_t actualMemoryUsageMB() { return 0; }
 
+    // If memory usage is below this threshold, do not bother forcing GC.
+    virtual size_t lowMemoryUsageMB() { return 256; }
+
+    // If memory usage is above this threshold, force GC more aggressively.
+    virtual size_t highMemoryUsageMB() { return 1024; }
+
+    // Delta of memory usage growth (vs. last actualMemoryUsageMB()) to force GC when memory usage is high.
+    virtual size_t highUsageDeltaMB() { return 128; }
+
 
     // Threads -------------------------------------------------------
 
index f7c707a..a481155 100644 (file)
@@ -1010,6 +1010,21 @@ int PlatformSupport::actualMemoryUsageMB()
     return static_cast<int>(webKitPlatformSupport()->actualMemoryUsageMB());
 }
 
+int PlatformSupport::lowMemoryUsageMB()
+{
+    return static_cast<int>(webKitPlatformSupport()->lowMemoryUsageMB());
+}
+
+int PlatformSupport::highMemoryUsageMB()
+{
+    return static_cast<int>(webKitPlatformSupport()->highMemoryUsageMB());
+}
+
+int PlatformSupport::highUsageDeltaMB()
+{
+    return static_cast<int>(webKitPlatformSupport()->highUsageDeltaMB());
+}
+
 int PlatformSupport::screenDepth(Widget* widget)
 {
     WebWidgetClient* client = toWebWidgetClient(widget);