| 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/memory_allocator_dump.h" | 18 #include "base/trace_event/memory_allocator_dump.h" |
| 18 #include "base/trace_event/memory_allocator_dump_guid.h" | 19 #include "base/trace_event/memory_allocator_dump_guid.h" |
| 19 #include "base/trace_event/memory_dump_request_args.h" | 20 #include "base/trace_event/memory_dump_request_args.h" |
| 20 #include "base/trace_event/memory_dump_session_state.h" | 21 #include "base/trace_event/memory_dump_session_state.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 AllocationRegister; |
| 34 class MemoryDumpSessionState; | 36 class MemoryDumpSessionState; |
| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 const MemoryAllocatorDumpGuid& guid); | 113 const MemoryAllocatorDumpGuid& guid); |
| 112 | 114 |
| 113 // Looks up a shared MemoryAllocatorDump given its guid. | 115 // Looks up a shared MemoryAllocatorDump given its guid. |
| 114 MemoryAllocatorDump* GetSharedGlobalAllocatorDump( | 116 MemoryAllocatorDump* GetSharedGlobalAllocatorDump( |
| 115 const MemoryAllocatorDumpGuid& guid) const; | 117 const MemoryAllocatorDumpGuid& guid) const; |
| 116 | 118 |
| 117 // Returns the map of the MemoryAllocatorDumps added to this dump. | 119 // Returns the map of the MemoryAllocatorDumps added to this dump. |
| 118 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; } | 120 const AllocatorDumpsMap& allocator_dumps() const { return allocator_dumps_; } |
| 119 | 121 |
| 120 // Dumps heap usage with |allocator_name|. | 122 // Dumps heap usage with |allocator_name|. |
| 121 void DumpHeapUsage(const base::hash_map<base::trace_event::AllocationContext, | 123 void DumpHeapUsage(const AllocationRegister& allocation_register, |
| 122 base::trace_event::AllocationMetrics>& | |
| 123 metrics_by_context, | |
| 124 base::trace_event::TraceEventMemoryOverhead& overhead, | |
| 125 const char* allocator_name); | 124 const char* allocator_name); |
| 126 | 125 |
| 127 // Adds an ownership relationship between two MemoryAllocatorDump(s) with the | 126 // Adds an ownership relationship between two MemoryAllocatorDump(s) with the |
| 128 // semantics: |source| owns |target|, and has the effect of attributing | 127 // semantics: |source| owns |target|, and has the effect of attributing |
| 129 // the memory usage of |target| to |source|. |importance| is optional and | 128 // the memory usage of |target| to |source|. |importance| is optional and |
| 130 // relevant only for the cases of co-ownership, where it acts as a z-index: | 129 // relevant only for the cases of co-ownership, where it acts as a z-index: |
| 131 // the owner with the highest importance will be attributed |target|'s memory. | 130 // the owner with the highest importance will be attributed |target|'s memory. |
| 132 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, | 131 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, |
| 133 const MemoryAllocatorDumpGuid& target, | 132 const MemoryAllocatorDumpGuid& target, |
| 134 int importance); | 133 int importance); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // background mode are disabled for testing. | 212 // background mode are disabled for testing. |
| 214 static bool is_black_hole_non_fatal_for_testing_; | 213 static bool is_black_hole_non_fatal_for_testing_; |
| 215 | 214 |
| 216 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); | 215 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); |
| 217 }; | 216 }; |
| 218 | 217 |
| 219 } // namespace trace_event | 218 } // namespace trace_event |
| 220 } // namespace base | 219 } // namespace base |
| 221 | 220 |
| 222 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ | 221 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ |
| OLD | NEW |