Commit small change to destroy events objects when destroying objects with
events. This removes a number of minor memory leaks with creating/destroying popups, layers, features, and markers. git-svn-id: http://svn.openlayers.org/trunk/openlayers@2894 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -59,7 +59,11 @@ OpenLayers.Feature.prototype= {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.events) {
|
||||||
|
this.events.destroy();
|
||||||
|
}
|
||||||
this.events = null;
|
this.events = null;
|
||||||
|
|
||||||
this.layer = null;
|
this.layer = null;
|
||||||
this.id = null;
|
this.id = null;
|
||||||
this.lonlat = null;
|
this.lonlat = null;
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ OpenLayers.Layer.prototype = {
|
|||||||
this.name = null;
|
this.name = null;
|
||||||
this.div = null;
|
this.div = null;
|
||||||
this.options = null;
|
this.options = null;
|
||||||
|
|
||||||
|
this.events.destroy();
|
||||||
this.events = null;
|
this.events = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,10 @@ OpenLayers.Marker.prototype = {
|
|||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
this.map = null;
|
this.map = null;
|
||||||
|
|
||||||
|
this.events.destroy();
|
||||||
|
this.events = null;
|
||||||
|
|
||||||
if (this.icon != null) {
|
if (this.icon != null) {
|
||||||
this.icon.destroy();
|
this.icon.destroy();
|
||||||
this.icon = null;
|
this.icon = null;
|
||||||
|
|||||||
@@ -117,9 +117,11 @@ OpenLayers.Popup.prototype = {
|
|||||||
destroy: function() {
|
destroy: function() {
|
||||||
if (this.map != null) {
|
if (this.map != null) {
|
||||||
this.map.removePopup(this);
|
this.map.removePopup(this);
|
||||||
|
this.map = null;
|
||||||
}
|
}
|
||||||
|
this.events.destroy();
|
||||||
|
this.events = null;
|
||||||
this.div = null;
|
this.div = null;
|
||||||
this.map = null;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -212,7 +212,8 @@
|
|||||||
t.eq(OpenLayers.Event.observers.length,
|
t.eq(OpenLayers.Event.observers.length,
|
||||||
start + OpenLayers.Events.prototype.BROWSER_EVENTS.length + 1,
|
start + OpenLayers.Events.prototype.BROWSER_EVENTS.length + 1,
|
||||||
"construction increases the number of event observers");
|
"construction increases the number of event observers");
|
||||||
events = events.destroy();
|
events.destroy();
|
||||||
|
events = null;
|
||||||
t.eq(OpenLayers.Event.observers.length, start,
|
t.eq(OpenLayers.Event.observers.length, start,
|
||||||
"destruction restores the number of event observers");
|
"destruction restores the number of event observers");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user