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

Side by Side Diff: base/memory/shared_memory_tracker.cc

Issue 2923123004: [memory-infra] Add API to ProcessMemoryDump to create ownership edges for base::SharedMemory (Closed)
Patch Set: add tests Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/memory/shared_memory_tracker.h" 5 #include "base/memory/shared_memory_tracker.h"
6 6
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/trace_event/memory_allocator_dump_guid.h" 9 #include "base/trace_event/memory_allocator_dump_guid.h"
10 #include "base/trace_event/memory_dump_manager.h" 10 #include "base/trace_event/memory_dump_manager.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 trace_event::MemoryAllocatorDump* local_dump = 82 trace_event::MemoryAllocatorDump* local_dump =
83 pmd->CreateAllocatorDump(dump_name); 83 pmd->CreateAllocatorDump(dump_name);
84 // TODO(hajimehoshi): The size is not resident size but virtual size so far. 84 // TODO(hajimehoshi): The size is not resident size but virtual size so far.
85 // Fix this to record resident size. 85 // Fix this to record resident size.
86 local_dump->AddScalar(trace_event::MemoryAllocatorDump::kNameSize, 86 local_dump->AddScalar(trace_event::MemoryAllocatorDump::kNameSize,
87 trace_event::MemoryAllocatorDump::kUnitsBytes, size); 87 trace_event::MemoryAllocatorDump::kUnitsBytes, size);
88 trace_event::MemoryAllocatorDump* global_dump = 88 trace_event::MemoryAllocatorDump* global_dump =
89 pmd->CreateSharedGlobalAllocatorDump(dump_guid); 89 pmd->CreateSharedGlobalAllocatorDump(dump_guid);
90 global_dump->AddScalar(trace_event::MemoryAllocatorDump::kNameSize, 90 global_dump->AddScalar(trace_event::MemoryAllocatorDump::kNameSize,
91 trace_event::MemoryAllocatorDump::kUnitsBytes, size); 91 trace_event::MemoryAllocatorDump::kUnitsBytes, size);
92 // TOOD(hajimehoshi): Detect which the shared memory comes from browser, 92
93 // renderer or GPU process. 93 // The edges will be overriden by the clients with correct importance.
94 // TODO(hajimehoshi): Shared memory reported by GPU and discardable is 94 pmd->AddOverridableOwnershipEdge(local_dump->guid(), global_dump->guid(),
95 // currently double-counted. Add ownership edges to avoid this. 95 0 /* importance */);
hajimehoshi 2017/06/08 05:10:05 I tend to think we should have ProcessMemoryDump::
ssid 2017/06/08 18:44:23 I think the users of edges should be aware of the
96 pmd->AddOwnershipEdge(local_dump->guid(), global_dump->guid());
97 } 96 }
98 return true; 97 return true;
99 } 98 }
100 99
101 SharedMemoryTracker::SharedMemoryTracker() { 100 SharedMemoryTracker::SharedMemoryTracker() {
102 trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider( 101 trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
103 this, "SharedMemoryTracker", nullptr); 102 this, "SharedMemoryTracker", nullptr);
104 } 103 }
105 104
106 SharedMemoryTracker::~SharedMemoryTracker() = default; 105 SharedMemoryTracker::~SharedMemoryTracker() = default;
107 106
108 } // namespace 107 } // namespace
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_allocator_dump_guid.h » ('j') | base/trace_event/memory_allocator_dump_guid.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698