summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-01 16:18:13 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-01 16:18:13 +0000
commitfc6544504d5b229a75bd2084fa3f98f599d4c27a (patch)
treef212ddde195f9e234817de97d2322e8a1b764474 /chrome
parent2017788243cf8862d9801ff744b87b2b524076ea (diff)
downloadchromium_src-fc6544504d5b229a75bd2084fa3f98f599d4c27a.zip
chromium_src-fc6544504d5b229a75bd2084fa3f98f599d4c27a.tar.gz
chromium_src-fc6544504d5b229a75bd2084fa3f98f599d4c27a.tar.bz2
Scale backing store cache size.
The approach is borrowed from render_process_host's kMaxRenderersByRamTier. The values were chosen to keep a minimal number of DIBs in the extreme low RAM case, and scale up linearly from there to the previous (constant) value of 5. Patch by Joel Stanley. BUG=12028 Review URL: http://codereview.chromium.org/115452 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17318 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/backing_store.cc19
1 files changed, 15 insertions, 4 deletions
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.