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

Unified Diff: ui/android/resources/resource_manager_impl.cc

Issue 2440393002: [tracing] Implement composable memory usage estimators. (Closed)
Patch Set: Rebase Created 4 years, 1 month 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 | « ui/android/resources/resource_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/android/resources/resource_manager_impl.cc
diff --git a/ui/android/resources/resource_manager_impl.cc b/ui/android/resources/resource_manager_impl.cc
index 2e60510bc44949c7936b9f35a5b79e8284412092..2e0cc894fe6979a91d694aa74db3256f91c391e9 100644
--- a/ui/android/resources/resource_manager_impl.cc
+++ b/ui/android/resources/resource_manager_impl.cc
@@ -16,6 +16,7 @@
#include "base/strings/stringprintf.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/memory_usage_estimator.h"
#include "base/trace_event/process_memory_dump.h"
#include "base/trace_event/trace_event.h"
#include "cc/resources/scoped_ui_resource.h"
@@ -301,31 +302,18 @@ ResourceManagerImpl::ProcessCrushedSpriteFrameRects(
bool ResourceManagerImpl::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
- size_t size = 0;
- for (const auto& resource_map : resources_) {
- for (const auto& id_and_resource : resource_map) {
- if (id_and_resource.second && id_and_resource.second->ui_resource)
- size += id_and_resource.second->ui_resource->GetAllocatedSizeInBytes();
- }
- }
- for (const auto& id_and_resource : crushed_sprite_resources_) {
- if (id_and_resource.second)
- size += id_and_resource.second->GetAllocatedSizeInBytes();
- }
- for (const auto& color_and_resources : tinted_resources_) {
- for (const auto& id_and_resource : *color_and_resources.second) {
- if (id_and_resource.second && id_and_resource.second->ui_resource)
- size += id_and_resource.second->ui_resource->GetAllocatedSizeInBytes();
- }
- }
+ size_t memory_usage =
+ base::trace_event::EstimateMemoryUsage(resources_) +
+ base::trace_event::EstimateMemoryUsage(crushed_sprite_resources_) +
+ base::trace_event::EstimateMemoryUsage(tinted_resources_);
base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(
base::StringPrintf("ui/resource_manager_0x%" PRIXPTR,
reinterpret_cast<uintptr_t>(this)));
dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
- base::trace_event::MemoryAllocatorDump::kUnitsBytes, size);
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ memory_usage);
- // Bitmaps are allocated from malloc.
const char* system_allocator_name =
base::trace_event::MemoryDumpManager::GetInstance()
->system_allocator_pool_name();
« no previous file with comments | « ui/android/resources/resource_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698