Skip to content

Commit

Permalink
Reset the evented parent when removing objects to break GC loop (#8813)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkaefer authored Oct 15, 2019
1 parent 036ddc4 commit 4077c78
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -1143,9 +1143,16 @@ class Style extends Evented {
this._spriteRequest = null;
}
rtlTextPluginEvented.off('pluginAvailable', this._rtlTextPluginCallback);
for (const layerId in this._layers) {
const layer: StyleLayer = this._layers[layerId];
layer.setEventedParent(null);
}
for (const id in this.sourceCaches) {
this.sourceCaches[id].clearTiles();
this.sourceCaches[id].setEventedParent(null);
}
this.imageManager.setEventedParent(null);
this.setEventedParent(null);
this.dispatcher.remove();
}

Expand Down
1 change: 1 addition & 0 deletions src/util/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class Actor {
}

remove() {
this.invoker.remove();
this.target.removeEventListener('message', this.receive, false);
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/util/throttled_invoker.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class ThrottledInvoker {
}
}
}

remove() {
delete this._channel;
this._callback = () => {};
}
}

export default ThrottledInvoker;

0 comments on commit 4077c78

Please sign in to comment.