Resolve memory leak when deleting a webgl layer

Various references were kept, preventing the layer and underlying
renderer and webgl context to be garbage collected.

Also, the Helper was simplified because it turns out deleting manually
all Webgl objects is useless: these objects will be released when
the context is garbage collected anyway.

Note: this touches the Layer and BaseLayer classes, as the following were
preventing the layer from being garbage collected:
* layer reference in the `state_` object in BaseLayer
* dangling listener for source change in Layer
This commit is contained in:
jahow
2019-10-30 21:59:57 +01:00
committed by Olivier Guyot
parent e5e03d46a0
commit f7b0f6750b
7 changed files with 43 additions and 35 deletions

View File

@@ -124,6 +124,7 @@ function refreshLayer(newStyle) {
if (previousLayer) {
map.removeLayer(previousLayer);
previousLayer.dispose();
}
literalStyle = newStyle;
}