| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_MEMORY_PEAK_DETECTOR_H_ | 5 #ifndef BASE_TRACE_EVENT_MEMORY_PEAK_DETECTOR_H_ |
| 6 #define BASE_TRACE_EVENT_MEMORY_PEAK_DETECTOR_H_ | 6 #define BASE_TRACE_EVENT_MEMORY_PEAK_DETECTOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/base_export.h" | 13 #include "base/base_export.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 | 17 |
| 18 namespace base { | 18 namespace base { |
| 19 | 19 |
| 20 class SequencedTaskRunner; | 20 class SequencedTaskRunner; |
| 21 | 21 |
| 22 namespace trace_event { | 22 namespace trace_event { |
| 23 | 23 |
| 24 struct MemoryDumpProviderInfo; | 24 struct MemoryDumpProviderInfo; |
| 25 | 25 |
| 26 // Detects temporally local memory peaks. Peak detection is based on | 26 // Detects temporally local memory peaks. Peak detection is based on |
| 27 // continuously querying memory usage using MemoryDumpprovider(s) that support | 27 // continuously querying memory usage using MemoryDumpprovider(s) that support |
| 28 // fast polling (e.g., ProcessMetricsDumpProvider which under the hoods reads | 28 // fast polling (e.g., ProcessMetricsDumpProvider which under the hoods reads |
| 29 // /proc/PID/statm on Linux) and using a cobination of: | 29 // /proc/PID/statm on Linux) and using a combination of: |
| 30 // - An static threshold (currently 1% of total system memory). | 30 // - An static threshold (currently 1% of total system memory). |
| 31 // - Sliding window stddev analysis. | 31 // - Sliding window stddev analysis. |
| 32 // Design doc: https://goo.gl/0kOU4A . | 32 // Design doc: https://goo.gl/0kOU4A . |
| 33 // This class is NOT thread-safe, the caller has to ensure linearization of | 33 // This class is NOT thread-safe, the caller has to ensure linearization of |
| 34 // the calls to the public methods. In any case, the public methods do NOT have | 34 // the calls to the public methods. In any case, the public methods do NOT have |
| 35 // to be called from the |task_runner| on which the polling tasks run. | 35 // to be called from the |task_runner| on which the polling tasks run. |
| 36 class BASE_EXPORT MemoryPeakDetector { | 36 class BASE_EXPORT MemoryPeakDetector { |
| 37 public: | 37 public: |
| 38 using OnPeakDetectedCallback = RepeatingClosure; | 38 using OnPeakDetectedCallback = RepeatingClosure; |
| 39 using DumpProvidersList = std::vector<scoped_refptr<MemoryDumpProviderInfo>>; | 39 using DumpProvidersList = std::vector<scoped_refptr<MemoryDumpProviderInfo>>; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 uint32_t samples_index_; | 175 uint32_t samples_index_; |
| 176 uint32_t poll_tasks_count_for_testing_; | 176 uint32_t poll_tasks_count_for_testing_; |
| 177 | 177 |
| 178 DISALLOW_COPY_AND_ASSIGN(MemoryPeakDetector); | 178 DISALLOW_COPY_AND_ASSIGN(MemoryPeakDetector); |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 } // namespace trace_event | 181 } // namespace trace_event |
| 182 } // namespace base | 182 } // namespace base |
| 183 | 183 |
| 184 #endif // BASE_TRACE_EVENT_MEMORY_PEAK_DETECTOR_H_ | 184 #endif // BASE_TRACE_EVENT_MEMORY_PEAK_DETECTOR_H_ |
| OLD | NEW |