Commit d3a4b891 authored by ccameron@chromium.org's avatar ccameron@chromium.org

Reduce per-tab memory to 128M maximum, reduce default maximum across all tabs to 256M.

The more appropriate fix is that we should be more aggressively discarding offscreen tiles, but this will temporarily fix some OOM issues that we're encountering on low-FB parts.

BUG=141377


Review URL: https://chromiumcodereview.appspot.com/10827342

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151778 0039d316-1c4b-4281-b951-d872f2087c98
parent 4adefbad
......@@ -86,7 +86,7 @@ GpuMemoryManager::GpuMemoryManager(GpuMemoryManagerClient* client,
#if defined(OS_ANDROID)
bytes_available_gpu_memory_ = 64 * 1024 * 1024;
#else
bytes_available_gpu_memory_ = 448 * 1024 * 1024;
bytes_available_gpu_memory_ = 256 * 1024 * 1024;
#endif
}
}
......@@ -262,6 +262,10 @@ void GpuMemoryManager::Manage() {
bonus_allocation = CalculateBonusMemoryAllocationBasedOnSize(
stubs_with_surface_foreground[0]->GetSurfaceSize());
#endif
size_t stubs_with_surface_foreground_allocation = GetMinimumTabAllocation() +
bonus_allocation;
if (stubs_with_surface_foreground_allocation >= GetMaximumTabAllocation())
stubs_with_surface_foreground_allocation = GetMaximumTabAllocation();
stub_memory_stats_for_last_manage_.clear();
......@@ -269,7 +273,7 @@ void GpuMemoryManager::Manage() {
AssignMemoryAllocations(
&stub_memory_stats_for_last_manage_,
stubs_with_surface_foreground,
GpuMemoryAllocation(GetMinimumTabAllocation() + bonus_allocation,
GpuMemoryAllocation(stubs_with_surface_foreground_allocation,
GpuMemoryAllocation::kHasFrontbuffer |
GpuMemoryAllocation::kHasBackbuffer),
true);
......
......@@ -87,6 +87,11 @@ class CONTENT_EXPORT GpuMemoryManager :
return bytes_available_gpu_memory_;
}
// The maximum amount of memory that a tab may be assigned
size_t GetMaximumTabAllocation() const {
return 128 * 1024 * 1024;
}
// The minimum non-zero amount of memory that a tab may be assigned
size_t GetMinimumTabAllocation() const {
#if defined(OS_ANDROID)
......
......@@ -159,6 +159,10 @@ class GpuMemoryManagerTest : public testing::Test {
return memory_manager_.GetAvailableGpuMemory();
}
size_t GetMaximumTabAllocation() {
return memory_manager_.GetMaximumTabAllocation();
}
size_t GetMinimumTabAllocation() {
return memory_manager_.GetMinimumTabAllocation();
}
......@@ -639,7 +643,8 @@ TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) {
EXPECT_TRUE(stats[&stub2].visible);
EXPECT_GT(stub1allocation2, 0ul);
EXPECT_GT(stub2allocation2, 0ul);
if (compositors_get_bonus_allocation)
if (compositors_get_bonus_allocation &&
stub1allocation2 != GetMaximumTabAllocation())
EXPECT_LT(stub1allocation2, stub1allocation1);
FakeCommandBufferStub stub3(GenerateUniqueSurfaceId(), true, older_);
......@@ -647,7 +652,7 @@ TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) {
Manage();
stats = memory_manager_.stub_memory_stats_for_last_manage();
size_t stub1allocation3 = stats[&stub1].allocation.gpu_resource_size_in_bytes;
size_t stub2allocation3 = stats[&stub1].allocation.gpu_resource_size_in_bytes;
size_t stub2allocation3 = stats[&stub2].allocation.gpu_resource_size_in_bytes;
size_t stub3allocation3 = stats[&stub3].allocation.gpu_resource_size_in_bytes;
EXPECT_EQ(stats.size(), 3ul);
......@@ -657,7 +662,8 @@ TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) {
EXPECT_GT(stub1allocation3, 0ul);
EXPECT_GT(stub2allocation3, 0ul);
EXPECT_GT(stub3allocation3, 0ul);
if (compositors_get_bonus_allocation)
if (compositors_get_bonus_allocation &&
stub1allocation3 != GetMaximumTabAllocation())
EXPECT_LT(stub1allocation3, stub1allocation2);
stub1.surface_state_.visible = false;
......@@ -674,6 +680,7 @@ TEST_F(GpuMemoryManagerTest, StubMemoryStatsForLastManageTests) {
EXPECT_EQ(stub1allocation4, 0ul);
EXPECT_GE(stub2allocation4, 0ul);
EXPECT_GT(stub3allocation4, 0ul);
if (compositors_get_bonus_allocation)
if (compositors_get_bonus_allocation &&
stub3allocation3 != GetMaximumTabAllocation())
EXPECT_GT(stub3allocation4, stub3allocation3);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment