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

Unified Diff: content/browser/resources/media/data_series.js

Issue 14880002: Fixes a memory leak when running webrtc-internals for a long time, by using a circular buffer of si… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix merge conflict Created 7 years, 7 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: content/browser/resources/media/data_series.js
diff --git a/content/browser/resources/media/data_series.js b/content/browser/resources/media/data_series.js
index f32c822c5539e1084689961e9cde5c54e0c9fd83..3dfad4e28077c1f02bb9cb3b1d4bac27705058c6 100644
--- a/content/browser/resources/media/data_series.js
+++ b/content/browser/resources/media/data_series.js
@@ -6,6 +6,8 @@
* A TimelineDataSeries collects an ordered series of (time, value) pairs,
* and converts them to graph points. It also keeps track of its color and
* current visibility state.
+ * It keeps MAX_STATS_DATA_POINT_BUFFER_SIZE data points at most. Old data
+ * points will be dropped when it reaches this size.
*/
var TimelineDataSeries = (function() {
'use strict';
@@ -35,6 +37,9 @@ var TimelineDataSeries = (function() {
addPoint: function(timeTicks, value) {
var time = new Date(timeTicks);
this.dataPoints_.push(new DataPoint(time, value));
+
+ if (this.dataPoints_.length > MAX_STATS_DATA_POINT_BUFFER_SIZE)
+ this.dataPoints_.shift();
},
isVisible: function() {
« no previous file with comments | « content/browser/media/webrtc_internals_browsertest.cc ('k') | content/browser/resources/media/stats_graph_helper.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698