提交 0aeea993 编写于 作者: 1 100pah

Fix #4105 (memory leak)

上级 1b862d76
...@@ -142,6 +142,10 @@ define(function (require) { ...@@ -142,6 +142,10 @@ define(function (require) {
this._firstRender = false; this._firstRender = false;
}, },
dispose: function () {
this._controller && this._controller.dispose();
},
_focusNodeAdjacency: function (e) { _focusNodeAdjacency: function (e) {
var data = this._model.getData(); var data = this._model.getData();
var graph = data.graph; var graph = data.graph;
......
...@@ -53,6 +53,11 @@ define(function (require) { ...@@ -53,6 +53,11 @@ define(function (require) {
this.group.removeAll(); this.group.removeAll();
}, },
dispose: function () {
this._mapDraw && this._mapDraw.remove();
this._mapDraw = null;
},
_renderSymbols: function (mapModel, ecModel, api) { _renderSymbols: function (mapModel, ecModel, api) {
var originalData = mapModel.originalData; var originalData = mapModel.originalData;
var group = this.group; var group = this.group;
......
...@@ -386,7 +386,7 @@ ...@@ -386,7 +386,7 @@
_clearController: function () { _clearController: function () {
var controller = this._controller; var controller = this._controller;
if (controller) { if (controller) {
controller.off('pan').off('zoom'); controller.dispose();
controller = null; controller = null;
} }
}, },
......
...@@ -36,6 +36,7 @@ define(function(require) { ...@@ -36,6 +36,7 @@ define(function(require) {
var theCoordId = dataZoomInfo.coordId; var theCoordId = dataZoomInfo.coordId;
// Do clean when a dataZoom changes its target coordnate system. // Do clean when a dataZoom changes its target coordnate system.
// Avoid memory leak, dispose all not-used-registered.
zrUtil.each(store, function (record, coordId) { zrUtil.each(store, function (record, coordId) {
var dataZoomInfos = record.dataZoomInfos; var dataZoomInfos = record.dataZoomInfos;
if (dataZoomInfos[theDataZoomId] if (dataZoomInfos[theDataZoomId]
...@@ -49,7 +50,6 @@ define(function(require) { ...@@ -49,7 +50,6 @@ define(function(require) {
cleanStore(store); cleanStore(store);
var record = store[theCoordId]; var record = store[theCoordId];
// Create if needed. // Create if needed.
if (!record) { if (!record) {
record = store[theCoordId] = { record = store[theCoordId] = {
...@@ -86,6 +86,7 @@ define(function(require) { ...@@ -86,6 +86,7 @@ define(function(require) {
var store = giveStore(api); var store = giveStore(api);
zrUtil.each(store, function (record) { zrUtil.each(store, function (record) {
record.controller.dispose();
var dataZoomInfos = record.dataZoomInfos; var dataZoomInfos = record.dataZoomInfos;
if (dataZoomInfos[dataZoomId]) { if (dataZoomInfos[dataZoomId]) {
delete dataZoomInfos[dataZoomId]; delete dataZoomInfos[dataZoomId];
...@@ -141,7 +142,7 @@ define(function(require) { ...@@ -141,7 +142,7 @@ define(function(require) {
function cleanStore(store) { function cleanStore(store) {
zrUtil.each(store, function (record, coordId) { zrUtil.each(store, function (record, coordId) {
if (!record.count) { if (!record.count) {
record.controller.off('pan').off('zoom'); record.controller.dispose();
delete store[coordId]; delete store[coordId];
} }
}); });
......
...@@ -32,6 +32,14 @@ define(function (require) { ...@@ -32,6 +32,14 @@ define(function (require) {
} }
this.group.silent = geoModel.get('silent'); this.group.silent = geoModel.get('silent');
},
remove: function () {
this._mapDraw && this._mapDraw.remove();
},
dispose: function () {
this._mapDraw && this._mapDraw.remove();
} }
}); });
}); });
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册