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

Side by Side Diff: base/trace_event/process_memory_dump.h

Issue 1793943002: Use sysctlbyname() to get kernel page size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed primiano's comments Created 4 years, 9 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
« no previous file with comments | « no previous file | base/trace_event/process_memory_dump.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_vector.h" 16 #include "base/memory/scoped_vector.h"
17 #include "base/trace_event/memory_allocator_dump.h" 17 #include "base/trace_event/memory_allocator_dump.h"
18 #include "base/trace_event/memory_allocator_dump_guid.h" 18 #include "base/trace_event/memory_allocator_dump_guid.h"
19 #include "base/trace_event/memory_dump_session_state.h" 19 #include "base/trace_event/memory_dump_session_state.h"
20 #include "base/trace_event/process_memory_maps.h" 20 #include "base/trace_event/process_memory_maps.h"
21 #include "base/trace_event/process_memory_totals.h" 21 #include "base/trace_event/process_memory_totals.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 23
24 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the 24 // Define COUNT_RESIDENT_BYTES_SUPPORTED if platform supports counting of the
25 // resident memory. 25 // resident memory.
26 // TODO(crbug.com/542671): COUNT_RESIDENT_BYTES_SUPPORTED is disabled on iOS 26 #if (defined(OS_POSIX) && !defined(OS_NACL)) || defined(OS_WIN)
27 // as it cause memory corruption on iOS 9.0+ devices.
28 #if (defined(OS_POSIX) && !defined(OS_NACL) && !defined(OS_IOS)) || \
29 defined(OS_WIN)
30 #define COUNT_RESIDENT_BYTES_SUPPORTED 27 #define COUNT_RESIDENT_BYTES_SUPPORTED
31 #endif 28 #endif
32 29
33 namespace base { 30 namespace base {
34 namespace trace_event { 31 namespace trace_event {
35 32
36 class MemoryDumpManager; 33 class MemoryDumpManager;
37 class MemoryDumpSessionState; 34 class MemoryDumpSessionState;
38 class TracedValue; 35 class TracedValue;
39 36
40 // ProcessMemoryDump is as a strongly typed container which holds the dumps 37 // ProcessMemoryDump is as a strongly typed container which holds the dumps
41 // produced by the MemoryDumpProvider(s) for a specific process. 38 // produced by the MemoryDumpProvider(s) for a specific process.
42 class BASE_EXPORT ProcessMemoryDump { 39 class BASE_EXPORT ProcessMemoryDump {
43 public: 40 public:
44 struct MemoryAllocatorDumpEdge { 41 struct MemoryAllocatorDumpEdge {
45 MemoryAllocatorDumpGuid source; 42 MemoryAllocatorDumpGuid source;
46 MemoryAllocatorDumpGuid target; 43 MemoryAllocatorDumpGuid target;
47 int importance; 44 int importance;
48 const char* type; 45 const char* type;
49 }; 46 };
50 47
51 // Maps allocator dumps absolute names (allocator_name/heap/subheap) to 48 // Maps allocator dumps absolute names (allocator_name/heap/subheap) to
52 // MemoryAllocatorDump instances. 49 // MemoryAllocatorDump instances.
53 using AllocatorDumpsMap = 50 using AllocatorDumpsMap =
54 std::unordered_map<std::string, scoped_ptr<MemoryAllocatorDump>>; 51 std::unordered_map<std::string, scoped_ptr<MemoryAllocatorDump>>;
55 52
56 using HeapDumpsMap = std::unordered_map<std::string, scoped_ptr<TracedValue>>; 53 using HeapDumpsMap = std::unordered_map<std::string, scoped_ptr<TracedValue>>;
57 54
58 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) 55 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED)
56 // Returns the number of bytes in a kernel memory page. Some platforms may
57 // have a different value for kernel page sizes from user page sizes. It is
58 // important to use kernel memory page sizes for resident bytes calculation.
59 // In most cases, the two are the same.
60 static size_t GetSystemPageSize();
61
59 // Returns the total bytes resident for a virtual address range, with given 62 // Returns the total bytes resident for a virtual address range, with given
60 // |start_address| and |mapped_size|. |mapped_size| is specified in bytes. The 63 // |start_address| and |mapped_size|. |mapped_size| is specified in bytes. The
61 // value returned is valid only if the given range is currently mmapped by the 64 // value returned is valid only if the given range is currently mmapped by the
62 // process. The |start_address| must be page-aligned. 65 // process. The |start_address| must be page-aligned.
63 static size_t CountResidentBytes(void* start_address, size_t mapped_size); 66 static size_t CountResidentBytes(void* start_address, size_t mapped_size);
64 #endif 67 #endif
65 68
66 ProcessMemoryDump(const scoped_refptr<MemoryDumpSessionState>& session_state); 69 ProcessMemoryDump(const scoped_refptr<MemoryDumpSessionState>& session_state);
67 ~ProcessMemoryDump(); 70 ~ProcessMemoryDump();
68 71
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // Keeps track of relationships between MemoryAllocatorDump(s). 192 // Keeps track of relationships between MemoryAllocatorDump(s).
190 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_; 193 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_;
191 194
192 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); 195 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump);
193 }; 196 };
194 197
195 } // namespace trace_event 198 } // namespace trace_event
196 } // namespace base 199 } // namespace base
197 200
198 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 201 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/process_memory_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698