Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
branch 2403: content: Use at most 128MB of discardable memory on Andr…
Browse files Browse the repository at this point in the history
…oid.

512MB is needed on desktop to not regress performance on
some important benchmarks but this limit is much more than
needed on Android. By reducing it to 128MB we can also
avoid using a different allocation size on Android. This
makes the discardable memory behavior more consistent
across platforms and improves the browser's ability to
purge memory on Android.

This change also reduces the amount of discardable memory
used on low end devices to 1/8th of the normal limit.

BUG=489174

Review URL: https://codereview.chromium.org/1013533002

Cr-Commit-Position: refs/heads/master@{#330754}
(cherry picked from commit df13fe3)
[email protected]

Review URL: https://codereview.chromium.org/1148303003

Cr-Commit-Position: refs/branch-heads/2403@{#38}
Cr-Branched-From: f54b809-refs/heads/master@{#330231}
  • Loading branch information
Bo Liu committed May 20, 2015
1 parent 2dd3fbd commit dbfde02
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 0 additions & 5 deletions content/child/child_discardable_shared_memory_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ namespace content {
namespace {

// Default allocation size.
#if defined(OS_ANDROID)
// Larger allocation size on Android to avoid reaching the FD-limit.
const size_t kAllocationSize = 32 * 1024 * 1024;
#else
const size_t kAllocationSize = 4 * 1024 * 1024;
#endif

// Global atomic to generate unique discardable shared memory IDs.
base::StaticAtomicSequenceNumber g_next_discardable_shared_memory_id;
Expand Down
11 changes: 10 additions & 1 deletion content/common/host_discardable_shared_memory_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down

0 comments on commit dbfde02

Please sign in to comment.