Skip to content

Commit c123ebc

Browse files
committed
Memory leak fix candidates: 1) purge must destroy scene2d otherwise rAF never stops; 2) scene2d.destroy should destroy the traces
(cherry picked from commit 8f6f2dd)
1 parent 46bbbae commit c123ebc

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/plots/gl2d/scene2d.js

+8
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ proto.destroy = function() {
318318

319319
this.glplot = null;
320320
this.stopped = true;
321+
322+
var traces = this.traces
323+
if(traces) {
324+
Object.keys(traces).map(function(key) {
325+
traces[key].dispose();
326+
traces[key] = null;
327+
})
328+
}
321329
};
322330

323331
proto.plot = function(fullData, calcData, fullLayout) {

src/plots/plots.js

+10
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,16 @@ plots.purge = function(gd) {
809809
// remove modebar
810810
if(fullLayout._modeBar) fullLayout._modeBar.destroy();
811811

812+
if(fullLayout._plots) {
813+
Object.keys(fullLayout._plots).map(function(key) {
814+
var plot = fullLayout._plots[key];
815+
if(plot._scene2d) {
816+
plot._scene2d.destroy();
817+
plot._scene2d = null;
818+
}
819+
});
820+
}
821+
812822
// data and layout
813823
delete gd.data;
814824
delete gd.layout;

0 commit comments

Comments
 (0)