Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Commit 0bcf0db

Browse files
committed
fix rickshaw memory leaks in dashboards
replacing the DOM element that rickshaw attached to is not enough to get rid of the lingering event listeners which keep the SVG DOM elements alive having one more level of DOM element fixes the issue and allows the garbage collector to do its work fixes issue #782
1 parent 2927b8c commit 0bcf0db

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

public/javascripts/dashboards/widgets/field_chart.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ function updateWidget_field_chart(widget, data) {
5858
return;
5959
}
6060

61-
graphElem.html("");
61+
// we need to replace the entire element that rickshaw touches, otherwise
62+
// it will leak event listeners and tons of DOM elements
63+
graphElem.html('<div class="graph_chart">');
6264

6365
var renderer = graphElem.attr("data-config-renderer");
6466

6567
var graph = new Rickshaw.Graph( {
66-
element: graphElem.get()[0],
68+
element: $('.graph_chart', graphElem)[0],
6769
width: 800,
6870
height: 70,
6971
interpolation: graphElem.attr("data-config-interpolation"),

public/javascripts/dashboards/widgets/search_result_chart.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ function updateWidget_search_result_chart(widget, data) {
3434
return;
3535
}
3636

37-
graphElem.html("");
37+
// we need to replace the entire element that rickshaw touches, otherwise
38+
// it will leak event listeners and tons of DOM elements
39+
graphElem.html('<div class="graph_chart">');
3840

3941
var graph = new Rickshaw.Graph( {
40-
element: graphElem.get()[0],
42+
element: $('.graph_chart', graphElem)[0],
4143
width: 800,
4244
height: 70,
4345
renderer: "bar",

0 commit comments

Comments
 (0)