summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--chrome/browser/renderer_host/backing_store.cc19
2 files changed, 16 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index 182aa64..f907400 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -39,3 +39,4 @@ Robert Sesek <rsesek@bluestatic.org>
Janwar Dinata <j.dinata@gmail.com>
Will Hirsch <chromium@willhirsch.co.uk>
Yoav Zilberberg <yoav.zilberberg@gmail.com>
+Joel Stanley <joel@jms.id.au>
diff --git a/chrome/browser/renderer_host/backing_store.cc b/chrome/browser/renderer_host/backing_store.cc
index 8f8a1c9..b354e59 100644
--- a/chrome/browser/renderer_host/backing_store.cc
+++ b/chrome/browser/renderer_host/backing_store.cc
@@ -4,7 +4,9 @@
#include "chrome/browser/renderer_host/backing_store.h"
+#include "base/sys_info.h"
#include "chrome/browser/renderer_host/render_widget_host.h"
+#include "chrome/common/chrome_constants.h"
namespace {
@@ -12,11 +14,20 @@ typedef OwningMRUCache<RenderWidgetHost*, BackingStore*> BackingStoreCache;
static BackingStoreCache* cache = NULL;
// Returns the size of the backing store cache.
-// TODO(iyengar) Make this dynamic, i.e. based on the available resources
-// on the machine.
static int GetBackingStoreCacheSize() {
- const int kMaxSize = 5;
- return kMaxSize;
+ // This uses a similar approach to GetMaxRendererProcessCount. The goal
+ // is to reduce memory pressure and swapping on low-resource machines.
+ static const int kMaxDibCountByRamTier[] = {
+ 2, // less than 256MB
+ 3, // 256MB
+ 4, // 512MB
+ 5 // 768MB and above
+ };
+
+ static int max_size = kMaxDibCountByRamTier[
+ std::min(base::SysInfo::AmountOfPhysicalMemoryMB() / 256,
+ static_cast<int>(arraysize(kMaxDibCountByRamTier)) - 1)];
+ return max_size;
}
// Creates the backing store for the host based on the dimensions passed in.