OLD | NEW |
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 Loading... |
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 */); |
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 |
OLD | NEW |