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:
@@ -57,6 +57,9 @@ import Layer from './Layer.js';
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* **Important: a `WebGLPoints` layer must be manually disposed when removed, otherwise the underlying WebGL context
|
||||
* will not be garbage collected.**
|
||||
*
|
||||
* Note that any property set in the options is set as a {@link module:ol/Object~BaseObject}
|
||||
* property on the layer object; for example, setting `title: 'My Title'` in the
|
||||
* options means that `title` is observable, and has get/set accessors.
|
||||
@@ -100,6 +103,15 @@ class WebGLPointsLayer extends Layer {
|
||||
attributes: this.parseResult_.attributes
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @inheritDoc
|
||||
*/
|
||||
disposeInternal() {
|
||||
this.renderer_.dispose();
|
||||
super.disposeInternal();
|
||||
}
|
||||
}
|
||||
|
||||
export default WebGLPointsLayer;
|
||||
|
||||
Reference in New Issue
Block a user