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

Side by Side Diff: chrome/browser/metrics/metrics_memory_details.cc

Issue 2396743002: Leak reports collect information about the memory usage (Closed)
Patch Set: New MetricsMemoryDetails constructor, no histogram data generated Created 4 years, 2 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 | « chrome/browser/metrics/metrics_memory_details.h ('k') | no next file » | 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 #include "chrome/browser/metrics/metrics_memory_details.h" 5 #include "chrome/browser/metrics/metrics_memory_details.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // Skip if a last record is found less than 30 minutes ago. 49 // Skip if a last record is found less than 30 minutes ago.
50 } else { 50 } else {
51 // Not reporting if it's the first record for |pid|. 51 // Not reporting if it's the first record for |pid|.
52 times_[pid] = current_time; 52 times_[pid] = current_time;
53 memory_sizes_[pid] = sample; 53 memory_sizes_[pid] = sample;
54 } 54 }
55 return false; 55 return false;
56 } 56 }
57 57
58 MetricsMemoryDetails::MetricsMemoryDetails( 58 MetricsMemoryDetails::MetricsMemoryDetails(
59 const base::Closure& callback, 59 const base::Closure& callback, MemoryGrowthTracker* memory_growth_tracker)
60 MemoryGrowthTracker* memory_growth_tracker) 60 : callback_(callback), memory_growth_tracker_(memory_growth_tracker),
61 : callback_(callback), memory_growth_tracker_(memory_growth_tracker) { 61 generate_histograms_(true) {}
62 memory_growth_tracker_ = memory_growth_tracker; 62
mwlodar 2016/10/12 21:50:52 Deleted as redundant.
63 } 63 MetricsMemoryDetails::MetricsMemoryDetails(
64 const base::Closure& callback, MemoryGrowthTracker* memory_growth_tracker,
65 bool generate_histograms)
66 : callback_(callback), memory_growth_tracker_(memory_growth_tracker),
67 generate_histograms_(generate_histograms) {}
64 68
65 MetricsMemoryDetails::~MetricsMemoryDetails() { 69 MetricsMemoryDetails::~MetricsMemoryDetails() {
66 } 70 }
67 71
68 void MetricsMemoryDetails::OnDetailsAvailable() { 72 void MetricsMemoryDetails::OnDetailsAvailable() {
69 UpdateHistograms(); 73 if (generate_histograms_)
74 UpdateHistograms();
75 AnalyzeMemoryGrowth();
Simon Que 2016/10/12 21:15:56 Since AnalyzeMemoryGrowth() is defined in a #if de
mwlodar 2016/10/12 21:50:52 Both should be outside this #if. Fixed.
70 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback_); 76 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback_);
71 } 77 }
72 78
73 void MetricsMemoryDetails::UpdateHistograms() { 79 void MetricsMemoryDetails::UpdateHistograms() {
74 // Reports a set of memory metrics to UMA. 80 // Reports a set of memory metrics to UMA.
75 81
76 const ProcessData& browser = *ChromeBrowser(); 82 const ProcessData& browser = *ChromeBrowser();
77 size_t aggregate_memory = 0; 83 size_t aggregate_memory = 0;
78 int chrome_count = 0; 84 int chrome_count = 0;
79 int extension_count = 0; 85 int extension_count = 0;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 case ProcessMemoryInformation::RENDERER_UNKNOWN: 119 case ProcessMemoryInformation::RENDERER_UNKNOWN:
114 NOTREACHED() << "Unknown renderer process type."; 120 NOTREACHED() << "Unknown renderer process type.";
115 continue; 121 continue;
116 case ProcessMemoryInformation::RENDERER_NORMAL: 122 case ProcessMemoryInformation::RENDERER_NORMAL:
117 default: 123 default:
118 // TODO(erikkay): Should we bother splitting out the other subtypes? 124 // TODO(erikkay): Should we bother splitting out the other subtypes?
119 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Renderer.Large2", 125 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Renderer.Large2",
120 sample / 1024); 126 sample / 1024);
121 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Renderer.Committed", 127 UMA_HISTOGRAM_MEMORY_LARGE_MB("Memory.Renderer.Committed",
122 committed / 1024); 128 committed / 1024);
123 int diff;
124 if (memory_growth_tracker_ &&
125 memory_growth_tracker_->UpdateSample(
126 browser.processes[index].pid, sample, &diff)) {
127 if (diff < 0)
128 UMA_HISTOGRAM_MEMORY_KB("Memory.RendererShrinkIn30Min", -diff);
129 else
130 UMA_HISTOGRAM_MEMORY_KB("Memory.RendererGrowthIn30Min", diff);
131 }
132 renderer_count++; 129 renderer_count++;
133 continue; 130 continue;
134 } 131 }
135 } 132 }
136 case content::PROCESS_TYPE_UTILITY: 133 case content::PROCESS_TYPE_UTILITY:
137 UMA_HISTOGRAM_MEMORY_KB("Memory.Utility", sample); 134 UMA_HISTOGRAM_MEMORY_KB("Memory.Utility", sample);
138 other_count++; 135 other_count++;
139 continue; 136 continue;
140 case content::PROCESS_TYPE_ZYGOTE: 137 case content::PROCESS_TYPE_ZYGOTE:
141 UMA_HISTOGRAM_MEMORY_KB("Memory.Zygote", sample); 138 UMA_HISTOGRAM_MEMORY_KB("Memory.Zygote", sample);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 100000000, 100); 300 100000000, 100);
304 UMA_HISTOGRAM_CUSTOM_COUNTS("Memory.Swap.NumWrites", swap_info().num_writes, 301 UMA_HISTOGRAM_CUSTOM_COUNTS("Memory.Swap.NumWrites", swap_info().num_writes,
305 1, 100000000, 100); 302 1, 100000000, 100);
306 303
307 if (swap_info().orig_data_size > 0 && swap_info().compr_data_size > 0) { 304 if (swap_info().orig_data_size > 0 && swap_info().compr_data_size > 0) {
308 UMA_HISTOGRAM_CUSTOM_COUNTS( 305 UMA_HISTOGRAM_CUSTOM_COUNTS(
309 "Memory.Swap.CompressionRatio", 306 "Memory.Swap.CompressionRatio",
310 swap_info().orig_data_size / swap_info().compr_data_size, 1, 20, 20); 307 swap_info().orig_data_size / swap_info().compr_data_size, 1, 20, 20);
311 } 308 }
312 } 309 }
310
311 void MetricsMemoryDetails::AnalyzeMemoryGrowth() {
312 const ProcessData& browser = *ChromeBrowser();
313 for (size_t index = 0; index < browser.processes.size(); index++) {
314 int sample = static_cast<int>(browser.processes[index].working_set.priv);
315
316 int diff;
317 if (memory_growth_tracker_ && memory_growth_tracker_->UpdateSample(
318 browser.processes[index].pid, sample, &diff)) {
319 if (generate_histograms_) {
320 if (diff < 0)
321 UMA_HISTOGRAM_MEMORY_KB("Memory.RendererShrinkIn30Min", -diff);
322 else
323 UMA_HISTOGRAM_MEMORY_KB("Memory.RendererGrowthIn30Min", diff);
324 }
325 }
326 }
327 }
328
313 #endif // defined(OS_CHROMEOS) 329 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_memory_details.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698