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_TOTALS_H_ | 5 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_TOTALS_H_ |
6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_TOTALS_H_ | 6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_TOTALS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 14 matching lines...) Expand all Loading... | |
25 | 25 |
26 // Called at trace generation time to populate the TracedValue. | 26 // Called at trace generation time to populate the TracedValue. |
27 void AsValueInto(TracedValue* value) const; | 27 void AsValueInto(TracedValue* value) const; |
28 | 28 |
29 // Clears up all the data collected. | 29 // Clears up all the data collected. |
30 void Clear(); | 30 void Clear(); |
31 | 31 |
32 uint64_t resident_set_bytes() const { return resident_set_bytes_; } | 32 uint64_t resident_set_bytes() const { return resident_set_bytes_; } |
33 void set_resident_set_bytes(uint64_t value) { resident_set_bytes_ = value; } | 33 void set_resident_set_bytes(uint64_t value) { resident_set_bytes_ = value; } |
34 | 34 |
35 // Platform-specific data that will be used to compute the | |
36 // PrivateMemoryFootprint. | |
37 struct PlatformPrivateFootprint { | |
38 // macOS 10.12+ | |
39 uint64_t phys_footprint_bytes = 0; | |
Mark Mentovai
2017/04/25 20:29:44
Like you did here. :)
| |
40 | |
41 // macOS [all versions] | |
42 uint64_t internal_bytes = 0; | |
43 uint64_t compressed_bytes = 0; | |
44 | |
45 // Linux, Android, ChromeOS | |
46 // TODO(hjd): https://crbug.com/707019 | |
47 uint64_t rss_anon_bytes = 0; | |
Mark Mentovai
2017/04/25 20:29:44
Should we only define the proper OS-specific field
erikchen
2017/04/25 20:49:46
I considered if-def-souping this, but these parame
| |
48 uint64_t vm_swap_bytes = 0; | |
49 | |
50 // On Windows, | |
51 // TBD: https://crbug.com/707022 | |
52 // On iOS, | |
53 // TBD: https://crbug.com/714961 | |
54 }; | |
55 PlatformPrivateFootprint& GetPlatformPrivateFootprint() { | |
56 return platform_private_footprint_; | |
57 } | |
58 | |
35 uint64_t peak_resident_set_bytes() const { return peak_resident_set_bytes_; } | 59 uint64_t peak_resident_set_bytes() const { return peak_resident_set_bytes_; } |
36 void set_peak_resident_set_bytes(uint64_t value) { | 60 void set_peak_resident_set_bytes(uint64_t value) { |
37 peak_resident_set_bytes_ = value; | 61 peak_resident_set_bytes_ = value; |
38 } | 62 } |
39 | 63 |
40 // On some platforms (recent linux kernels, see goo.gl/sMvAVz) the peak rss | 64 // On some platforms (recent linux kernels, see goo.gl/sMvAVz) the peak rss |
41 // can be reset. When is_peak_rss_resettable == true, the peak refers to | 65 // can be reset. When is_peak_rss_resettable == true, the peak refers to |
42 // peak from the previous measurement. When false, it is the absolute peak | 66 // peak from the previous measurement. When false, it is the absolute peak |
43 // since the start of the process. | 67 // since the start of the process. |
44 bool is_peak_rss_resetable() const { return is_peak_rss_resetable_; } | 68 bool is_peak_rss_resetable() const { return is_peak_rss_resetable_; } |
45 void set_is_peak_rss_resetable(bool value) { is_peak_rss_resetable_ = value; } | 69 void set_is_peak_rss_resetable(bool value) { is_peak_rss_resetable_ = value; } |
46 | 70 |
47 void SetExtraFieldInBytes(const char* name, uint64_t value); | 71 void SetExtraFieldInBytes(const char* name, uint64_t value); |
48 | 72 |
49 private: | 73 private: |
50 uint64_t resident_set_bytes_; | 74 uint64_t resident_set_bytes_; |
51 uint64_t peak_resident_set_bytes_; | 75 uint64_t peak_resident_set_bytes_; |
52 bool is_peak_rss_resetable_; | 76 bool is_peak_rss_resetable_; |
53 | 77 |
78 // Not emitted in the trace as this is intended to be an intermediary in | |
79 // computation of private memory footprint. | |
80 PlatformPrivateFootprint platform_private_footprint_; | |
81 | |
54 // Extra metrics for OS-specific statistics. | 82 // Extra metrics for OS-specific statistics. |
55 std::map<const char*, uint64_t> extra_fields_; | 83 std::map<const char*, uint64_t> extra_fields_; |
56 | 84 |
57 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryTotals); | 85 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryTotals); |
58 }; | 86 }; |
59 | 87 |
60 } // namespace trace_event | 88 } // namespace trace_event |
61 } // namespace base | 89 } // namespace base |
62 | 90 |
63 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_TOTALS_H_ | 91 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_TOTALS_H_ |
OLD | NEW |