diff --git a/debug/tests/detached-dom-memory-leak.html b/debug/tests/detached-dom-memory-leak.html new file mode 100644 index 00000000..220cfe11 --- /dev/null +++ b/debug/tests/detached-dom-memory-leak.html @@ -0,0 +1,56 @@ + + + + Leaflet debug page + + + + + + + + + +This page will destroy and recreate a map div lots of times. Developer tools shall not display a memory leak. + +
+ + + +
+ + + \ No newline at end of file diff --git a/src/map/Map.js b/src/map/Map.js index f0c0c162..8dca0f26 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -272,6 +272,10 @@ L.Map = L.Evented.extend({ this.fire('unload'); } + for (var i in this._layers) { + this._layers[i].remove(); + } + return this; },