| 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 <map> | 10 #include <map> |
| 11 #include <unordered_map> | 11 #include <unordered_map> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/base_export.h" | 14 #include "base/base_export.h" |
| 15 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" | 16 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/scoped_vector.h" | 18 #include "base/memory/scoped_vector.h" |
| 18 #include "base/trace_event/heap_profiler_serialization_state.h" | 19 #include "base/trace_event/heap_profiler_serialization_state.h" |
| 19 #include "base/trace_event/memory_allocator_dump.h" | 20 #include "base/trace_event/memory_allocator_dump.h" |
| 20 #include "base/trace_event/memory_allocator_dump_guid.h" | 21 #include "base/trace_event/memory_allocator_dump_guid.h" |
| 21 #include "base/trace_event/memory_dump_request_args.h" | 22 #include "base/trace_event/memory_dump_request_args.h" |
| 22 #include "base/trace_event/process_memory_maps.h" | 23 #include "base/trace_event/process_memory_maps.h" |
| 23 #include "base/trace_event/process_memory_totals.h" | 24 #include "base/trace_event/process_memory_totals.h" |
| 24 #include "build/build_config.h" | 25 #include "build/build_config.h" |
| 25 | 26 |
| 26 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the | 27 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the |
| 27 // resident memory. | 28 // resident memory. |
| 28 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN) | 29 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN) |
| 29 #define COUNT_RESIDENT_BYTES_SUPPORTED | 30 #define COUNT_RESIDENT_BYTES_SUPPORTED |
| 30 #endif | 31 #endif |
| 31 | 32 |
| 32 namespace base { | 33 namespace base { |
| 33 | 34 |
| 34 class UnguessableToken; | 35 class UnguessableToken; |
| 35 | 36 |
| 36 namespace trace_event { | 37 namespace trace_event { |
| 37 | 38 |
| 39 class ShardedAllocationRegister; |
| 38 class HeapProfilerSerializationState; | 40 class HeapProfilerSerializationState; |
| 39 class TracedValue; | 41 class TracedValue; |
| 40 | 42 |
| 41 // ProcessMemoryDump is as a strongly typed container which holds the dumps | 43 // ProcessMemoryDump is as a strongly typed container which holds the dumps |
| 42 // produced by the MemoryDumpProvider(s) for a specific process. | 44 // produced by the MemoryDumpProvider(s) for a specific process. |
| 43 class BASE_EXPORT ProcessMemoryDump { | 45 class BASE_EXPORT ProcessMemoryDump { |
| 44 public: | 46 public: |
| 45 struct MemoryAllocatorDumpEdge { | 47 struct MemoryAllocatorDumpEdge { |
| 46 MemoryAllocatorDumpGuid source; | 48 MemoryAllocatorDumpGuid source; |
| 47 MemoryAllocatorDumpGuid target; | 49 MemoryAllocatorDumpGuid target; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 const MemoryAllocatorDumpGuid& guid); | 123 const MemoryAllocatorDumpGuid& guid); |
| 122 | 124 |
| 123 // Looks up a shared MemoryAllocatorDump given its guid. | 125 // Looks up a shared MemoryAllocatorDump given its guid. |
| 124 MemoryAllocatorDump* GetSharedGlobalAllocatorDump( | 126 MemoryAllocatorDump* GetSharedGlobalAllocatorDump( |
| 125 const MemoryAllocatorDumpGuid& guid) const; | 127 const MemoryAllocatorDumpGuid& guid) const; |
| 126 | 128 |
| 127 // Returns the map of the MemoryAllocatorDumps added to this dump. | 129 // Returns the map of the MemoryAllocatorDumps added to this dump. |
| 128 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; } | 130 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; } |
| 129 | 131 |
| 130 // Dumps heap usage with |allocator_name|. | 132 // Dumps heap usage with |allocator_name|. |
| 131 void DumpHeapUsage( | 133 void DumpHeapUsage(const ShardedAllocationRegister& allocation_register, |
| 132 const std::unordered_map<base::trace_event::AllocationContext, | 134 const char* allocator_name); |
| 133 base::trace_event::AllocationMetrics>& | |
| 134 metrics_by_context, | |
| 135 base::trace_event::TraceEventMemoryOverhead& overhead, | |
| 136 const char* allocator_name); | |
| 137 | 135 |
| 138 // Adds an ownership relationship between two MemoryAllocatorDump(s) with the | 136 // Adds an ownership relationship between two MemoryAllocatorDump(s) with the |
| 139 // semantics: |source| owns |target|, and has the effect of attributing | 137 // semantics: |source| owns |target|, and has the effect of attributing |
| 140 // the memory usage of |target| to |source|. |importance| is optional and | 138 // the memory usage of |target| to |source|. |importance| is optional and |
| 141 // relevant only for the cases of co-ownership, where it acts as a z-index: | 139 // relevant only for the cases of co-ownership, where it acts as a z-index: |
| 142 // the owner with the highest importance will be attributed |target|'s memory. | 140 // the owner with the highest importance will be attributed |target|'s memory. |
| 143 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, | 141 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, |
| 144 const MemoryAllocatorDumpGuid& target, | 142 const MemoryAllocatorDumpGuid& target, |
| 145 int importance); | 143 int importance); |
| 146 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, | 144 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 // background mode are disabled for testing. | 265 // background mode are disabled for testing. |
| 268 static bool is_black_hole_non_fatal_for_testing_; | 266 static bool is_black_hole_non_fatal_for_testing_; |
| 269 | 267 |
| 270 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); | 268 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); |
| 271 }; | 269 }; |
| 272 | 270 |
| 273 } // namespace trace_event | 271 } // namespace trace_event |
| 274 } // namespace base | 272 } // namespace base |
| 275 | 273 |
| 276 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ | 274 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ |
| OLD | NEW |