OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ | 5 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ |
6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ | 6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <unordered_map> | 10 #include <unordered_map> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
| 14 #include "base/gtest_prod_util.h" |
14 #include "base/macros.h" | 15 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
17 #include "base/trace_event/heap_profiler_serialization_state.h" | 18 #include "base/trace_event/heap_profiler_serialization_state.h" |
18 #include "base/trace_event/memory_allocator_dump.h" | 19 #include "base/trace_event/memory_allocator_dump.h" |
19 #include "base/trace_event/memory_allocator_dump_guid.h" | 20 #include "base/trace_event/memory_allocator_dump_guid.h" |
20 #include "base/trace_event/memory_dump_request_args.h" | 21 #include "base/trace_event/memory_dump_request_args.h" |
21 #include "base/trace_event/process_memory_maps.h" | 22 #include "base/trace_event/process_memory_maps.h" |
22 #include "base/trace_event/process_memory_totals.h" | 23 #include "base/trace_event/process_memory_totals.h" |
23 #include "build/build_config.h" | 24 #include "build/build_config.h" |
24 | 25 |
25 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the | 26 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the |
26 // resident memory. | 27 // resident memory. |
27 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN) | 28 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN) |
28 #define COUNT_RESIDENT_BYTES_SUPPORTED | 29 #define COUNT_RESIDENT_BYTES_SUPPORTED |
29 #endif | 30 #endif |
30 | 31 |
31 namespace base { | 32 namespace base { |
32 namespace trace_event { | 33 namespace trace_event { |
33 | 34 |
| 35 class ShardedAllocationRegister; |
34 class HeapProfilerSerializationState; | 36 class HeapProfilerSerializationState; |
35 class TracedValue; | 37 class TracedValue; |
36 | 38 |
37 // ProcessMemoryDump is as a strongly typed container which holds the dumps | 39 // ProcessMemoryDump is as a strongly typed container which holds the dumps |
38 // produced by the MemoryDumpProvider(s) for a specific process. | 40 // produced by the MemoryDumpProvider(s) for a specific process. |
39 class BASE_EXPORT ProcessMemoryDump { | 41 class BASE_EXPORT ProcessMemoryDump { |
40 public: | 42 public: |
41 struct MemoryAllocatorDumpEdge { | 43 struct MemoryAllocatorDumpEdge { |
42 MemoryAllocatorDumpGuid source; | 44 MemoryAllocatorDumpGuid source; |
43 MemoryAllocatorDumpGuid target; | 45 MemoryAllocatorDumpGuid target; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 const MemoryAllocatorDumpGuid& guid); | 114 const MemoryAllocatorDumpGuid& guid); |
113 | 115 |
114 // Looks up a shared MemoryAllocatorDump given its guid. | 116 // Looks up a shared MemoryAllocatorDump given its guid. |
115 MemoryAllocatorDump* GetSharedGlobalAllocatorDump( | 117 MemoryAllocatorDump* GetSharedGlobalAllocatorDump( |
116 const MemoryAllocatorDumpGuid& guid) const; | 118 const MemoryAllocatorDumpGuid& guid) const; |
117 | 119 |
118 // Returns the map of the MemoryAllocatorDumps added to this dump. | 120 // Returns the map of the MemoryAllocatorDumps added to this dump. |
119 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; } | 121 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; } |
120 | 122 |
121 // Dumps heap usage with |allocator_name|. | 123 // Dumps heap usage with |allocator_name|. |
122 void DumpHeapUsage( | 124 void DumpHeapUsage(const ShardedAllocationRegister& allocation_register, |
123 const std::unordered_map<base::trace_event::AllocationContext, | 125 const char* allocator_name); |
124 base::trace_event::AllocationMetrics>& | |
125 metrics_by_context, | |
126 base::trace_event::TraceEventMemoryOverhead& overhead, | |
127 const char* allocator_name); | |
128 | 126 |
129 // Adds an ownership relationship between two MemoryAllocatorDump(s) with the | 127 // Adds an ownership relationship between two MemoryAllocatorDump(s) with the |
130 // semantics: |source| owns |target|, and has the effect of attributing | 128 // semantics: |source| owns |target|, and has the effect of attributing |
131 // the memory usage of |target| to |source|. |importance| is optional and | 129 // the memory usage of |target| to |source|. |importance| is optional and |
132 // relevant only for the cases of co-ownership, where it acts as a z-index: | 130 // relevant only for the cases of co-ownership, where it acts as a z-index: |
133 // the owner with the highest importance will be attributed |target|'s memory. | 131 // the owner with the highest importance will be attributed |target|'s memory. |
134 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, | 132 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, |
135 const MemoryAllocatorDumpGuid& target, | 133 const MemoryAllocatorDumpGuid& target, |
136 int importance); | 134 int importance); |
137 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, | 135 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // background mode are disabled for testing. | 216 // background mode are disabled for testing. |
219 static bool is_black_hole_non_fatal_for_testing_; | 217 static bool is_black_hole_non_fatal_for_testing_; |
220 | 218 |
221 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); | 219 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); |
222 }; | 220 }; |
223 | 221 |
224 } // namespace trace_event | 222 } // namespace trace_event |
225 } // namespace base | 223 } // namespace base |
226 | 224 |
227 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ | 225 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ |
OLD | NEW |