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

Unified Diff: content/common/host_discardable_shared_memory_manager.cc

Issue 1013533002: content: Use at most 128MB of discardable memory on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: include low-end device tuning Created 5 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 | « content/child/child_discardable_shared_memory_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/host_discardable_shared_memory_manager.cc
diff --git a/content/common/host_discardable_shared_memory_manager.cc b/content/common/host_discardable_shared_memory_manager.cc
index 99db11720c7c9665d133291f2e691d8b848036d2..69f6e18e9d9f77bc1a38a916a0c4a6860e3ad15e 100644
--- a/content/common/host_discardable_shared_memory_manager.cc
+++ b/content/common/host_discardable_shared_memory_manager.cc
@@ -68,7 +68,12 @@ class DiscardableMemoryImpl : public base::DiscardableMemory {
base::LazyInstance<HostDiscardableSharedMemoryManager>
g_discardable_shared_memory_manager = LAZY_INSTANCE_INITIALIZER;
+#if defined(OS_ANDROID)
+// Limits the number of FDs used to 32, assuming a 4MB allocation size.
+const int64_t kMaxDefaultMemoryLimit = 128 * 1024 * 1024;
+#else
const int64_t kMaxDefaultMemoryLimit = 512 * 1024 * 1024;
+#endif
const int kEnforceMemoryPolicyDelayMs = 1000;
@@ -89,7 +94,11 @@ HostDiscardableSharedMemoryManager::HostDiscardableSharedMemoryManager()
: memory_limit_(
// Allow 25% of physical memory to be used for discardable memory.
std::min(base::SysInfo::AmountOfPhysicalMemory() / 4,
- kMaxDefaultMemoryLimit)),
+ base::SysInfo::IsLowEndDevice()
+ ?
+ // Use 1/8th of discardable memory on low-end devices.
+ kMaxDefaultMemoryLimit / 8
+ : kMaxDefaultMemoryLimit)),
bytes_allocated_(0),
memory_pressure_listener_(new base::MemoryPressureListener(
base::Bind(&HostDiscardableSharedMemoryManager::OnMemoryPressure,
« no previous file with comments | « content/child/child_discardable_shared_memory_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698