Commit fc3ad4fd authored by Siddhartha's avatar Siddhartha Committed by Commit Bot

Add more details about UI resources in memory dump

Add details about number of resources and type of bitmap in UI resource
memory dump.

BUG=780547

Change-Id: Iaea7854db074a74a2a1340881ae3450756e74525
Reviewed-on: https://chromium-review.googlesource.com/879593
Commit-Queue: Siddhartha S <ssid@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Cr-Commit-Position: refs/heads/master@{#531735}
parent a22eb8ca
...@@ -176,7 +176,8 @@ const char* const kAllocatorDumpNameWhitelist[] = { ...@@ -176,7 +176,8 @@ const char* const kAllocatorDumpNameWhitelist[] = {
"skia/sk_glyph_cache", "skia/sk_glyph_cache",
"skia/sk_resource_cache", "skia/sk_resource_cache",
"sqlite", "sqlite",
"ui/resource_manager_0x?", "ui/resource_manager_0x?/default_resource/0x?",
"ui/resource_manager_0x?/tinted_resource",
"v8/isolate_0x?/contexts/detached_context", "v8/isolate_0x?/contexts/detached_context",
"v8/isolate_0x?/contexts/native_context", "v8/isolate_0x?/contexts/native_context",
"v8/isolate_0x?/heap_spaces", "v8/isolate_0x?/heap_spaces",
......
...@@ -34,6 +34,27 @@ using base::android::JavaArrayOfIntArrayToIntVector; ...@@ -34,6 +34,27 @@ using base::android::JavaArrayOfIntArrayToIntVector;
using base::android::JavaParamRef; using base::android::JavaParamRef;
using base::android::JavaRef; using base::android::JavaRef;
namespace {
base::trace_event::MemoryAllocatorDump* CreateMemoryDump(
const std::string& name,
size_t memory_usage,
base::trace_event::ProcessMemoryDump* pmd) {
base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(name);
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
memory_usage);
static const char* system_allocator_name =
base::trace_event::MemoryDumpManager::GetInstance()
->system_allocator_pool_name();
if (system_allocator_name)
pmd->AddSuballocation(dump->guid(), system_allocator_name);
return dump;
}
} // namespace
namespace ui { namespace ui {
// static // static
...@@ -212,24 +233,21 @@ void ResourceManagerImpl::RemoveResource( ...@@ -212,24 +233,21 @@ void ResourceManagerImpl::RemoveResource(
bool ResourceManagerImpl::OnMemoryDump( bool ResourceManagerImpl::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args, const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) { base::trace_event::ProcessMemoryDump* pmd) {
size_t memory_usage = std::string prefix = base::StringPrintf("ui/resource_manager_0x%" PRIXPTR,
base::trace_event::EstimateMemoryUsage(resources_) + reinterpret_cast<uintptr_t>(this));
base::trace_event::EstimateMemoryUsage(tinted_resources_); for (uint32_t type = static_cast<uint32_t>(ANDROID_RESOURCE_TYPE_FIRST);
type <= static_cast<uint32_t>(ANDROID_RESOURCE_TYPE_LAST); ++type) {
base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( size_t usage = base::trace_event::EstimateMemoryUsage(resources_[type]);
base::StringPrintf("ui/resource_manager_0x%" PRIXPTR, auto* dump = CreateMemoryDump(
reinterpret_cast<uintptr_t>(this))); prefix + base::StringPrintf("/default_resource/0x%u",
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, static_cast<uint32_t>(type)),
base::trace_event::MemoryAllocatorDump::kUnitsBytes, usage, pmd);
memory_usage); dump->AddScalar("resource_count", "objects", resources_[type].size());
const char* system_allocator_name =
base::trace_event::MemoryDumpManager::GetInstance()
->system_allocator_pool_name();
if (system_allocator_name) {
pmd->AddSuballocation(dump->guid(), system_allocator_name);
} }
size_t tinted_resource_usage =
base::trace_event::EstimateMemoryUsage(tinted_resources_);
CreateMemoryDump(prefix + "/tinted_resource", tinted_resource_usage, pmd);
return true; return true;
} }
......
...@@ -154,8 +154,8 @@ TEST_F(ResourceManagerTest, TestOnMemoryDumpEmitsData) { ...@@ -154,8 +154,8 @@ TEST_F(ResourceManagerTest, TestOnMemoryDumpEmitsData) {
const char* system_allocator_pool_name = const char* system_allocator_pool_name =
base::trace_event::MemoryDumpManager::GetInstance() base::trace_event::MemoryDumpManager::GetInstance()
->system_allocator_pool_name(); ->system_allocator_pool_name();
size_t expected_dump_count = system_allocator_pool_name ? 2 : 1; size_t kExpectedDumpCount = 10;
EXPECT_EQ(expected_dump_count, allocator_dumps.size()); EXPECT_EQ(kExpectedDumpCount, allocator_dumps.size());
for (const auto& dump : allocator_dumps) { for (const auto& dump : allocator_dumps) {
ASSERT_TRUE(dump.first.find("ui/resource_manager") == 0 || ASSERT_TRUE(dump.first.find("ui/resource_manager") == 0 ||
dump.first.find(system_allocator_pool_name) == 0); dump.first.find(system_allocator_pool_name) == 0);
......
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