Chromium Code Reviews| Index: components/metrics/leak_detector/leak_detector_impl.h |
| diff --git a/components/metrics/leak_detector/leak_detector_impl.h b/components/metrics/leak_detector/leak_detector_impl.h |
| index bf6a58e60165d32369491148b8145a26732cb38e..91f00d9ad3be05803f98bfc357ca39ac3ec5e354 100644 |
| --- a/components/metrics/leak_detector/leak_detector_impl.h |
| +++ b/components/metrics/leak_detector/leak_detector_impl.h |
| @@ -67,6 +67,15 @@ class LeakDetectorImpl { |
| return alloc_breakdown_history_; |
| } |
| + size_t num_rising_intervals() const { return num_rising_intervals_; } |
| + |
| + uint32_t num_allocs_increase() const { return num_allocs_increase_; } |
| + |
| + // Transform number of allocation events into number of analysis intervals. |
| + void normalize_num_rising_intervals(size_t timeslot_size) { |
|
Simon Que
2016/10/11 01:11:06
This is a bad design pattern because you could cal
mwlodar
2016/10/11 07:13:24
Done.
|
| + num_rising_intervals_ /= timeslot_size; |
| + } |
| + |
| // Used to compare the contents of two leak reports. |
| bool operator<(const LeakReport& other) const; |
| @@ -78,6 +87,12 @@ class LeakDetectorImpl { |
| // Number of bytes allocated by the leak site during each allocation. |
| size_t alloc_size_bytes_; |
| + // Number of intervals in the last uptrend. |
| + size_t num_rising_intervals_; |
| + |
| + // Net number of bytes allocated in the last uptrend. |
| + uint32_t num_allocs_increase_; |
| + |
| // Unlike the CallStack struct, which consists of addresses, this call stack |
| // will contain offsets in the executable binary. |
| InternalVector<uintptr_t> call_stack_; |
| @@ -105,7 +120,7 @@ class LeakDetectorImpl { |
| void RecordFree(const void* ptr); |
| // Run check for possible leaks based on the current profiling data. |
| - void TestForLeaks(InternalVector<LeakReport>* reports); |
| + void TestForLeaks(InternalVector<LeakReport>* reports, size_t timestamp); |
|
Simon Que
2016/10/11 01:11:06
Explain the role of |timestamp| in the comments.
mwlodar
2016/10/11 07:13:24
I have added comments below.
|
| private: |
| // A record of allocations for a particular size. |
| @@ -164,13 +179,13 @@ class LeakDetectorImpl { |
| // Not all the net alloc counts are recorded. And the number of historical |
| // records kept is capped. If adding a new record exceeds that limit, the |
| // oldest record is discarded. See the function definition for more details. |
| - void RecordCurrentAllocationDataInHistory(); |
| + void RecordCurrentAllocationDataInHistory(size_t timestamp); |
| // Store the data collected by RecordCurrentAllocationDataInHistory() in |
| // |*report|. Not all net alloc counts per call site will be stored, only the |
| // count for size=|size| and made from |call_site|. |
| void StoreHistoricalDataInReport(size_t size, const CallStack* call_site, |
| - LeakReport* report); |
| + LeakReport* report, size_t timestamp); |
| // Decrements the cooldown counter (value) for each entry in |
| // |cooldowns_per_leak_|. If the cooldown counter reaches 0, the entry is |