Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: chrome/browser/renderer_host/backing_store.cc

Issue 115452: Scale backing store cache size (Closed)
Patch Set: less out of bounds array access Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/backing_store.cc
diff --git a/chrome/browser/renderer_host/backing_store.cc b/chrome/browser/renderer_host/backing_store.cc
index 8f8a1c98f925ad728b3a48362239911983bf870e..b354e5944822ca803a586c1cb126b1e131ff28fe 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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698