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

Unified Diff: components/metrics/leak_detector/leak_detector_impl.h

Issue 1892283004: Add cooldown to LeakDetectorImpl leak report generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased; remove JuliaSet history comparison Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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 50a8a6e4e86003199d36099724679df0d23bf2a8..4fdf9107bc42d5c094cafa4842221e27382be65d 100644
--- a/components/metrics/leak_detector/leak_detector_impl.h
+++ b/components/metrics/leak_detector/leak_detector_impl.h
@@ -172,6 +172,22 @@ class LeakDetectorImpl {
void StoreHistoricalDataInReport(size_t size, const CallStack* call_site,
LeakReport* report);
+ // Decrements the cooldown counter (value) for each entry in
+ // |cooldowns_per_leak_|. If the cooldown counter reaches 0, the entry is
+ // removed. Thus, all extantentries in |cooldowns_per_leak_| maintain a
+ // positive count.
+ void UpdateLeakCooldowns();
+
+ // Returns true if a particular leak signature (alloc size + call site) does
+ // not have an active cooldown counter (i.e. does not have an entry in
+ // |cooldowns_per_leak_|.
+ bool ReadyToGenerateReport(size_t size, const CallStack* call_stack) const;
+
+ // Resets the counter for a leak signature (alloc size + call site) in
+ // |cooldowns_per_leak_| to the max cooldown value. Creates a new entry in the
+ // container if none exists for this leak signature.
+ void ResetLeakCooldown(size_t size, const CallStack* call_stack);
+
// Owns all unique call stack objects, which are allocated on the heap. Any
// other class or function that references a call stack must get it from here,
// but may not take ownership of the call stack object.
@@ -206,6 +222,11 @@ class LeakDetectorImpl {
// added to the tail of the list.
InternalList<InternalVector<uint32_t>> size_breakdown_history_;
+ // Key: leak signature (alloc size + call site)
+ // Value: number of leak analyses before another leak report can be generated
+ // for that leak.
+ std::map<std::pair<size_t, const CallStack*>, size_t> cooldowns_per_leak_;
+
// Address mapping info of the current binary.
uintptr_t mapping_addr_;
size_t mapping_size_;

Powered by Google App Engine
This is Rietveld 408576698