-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tile textures are retained indefinitely when raster sources are removed #3951
Comments
Thanks for the report! This issue actually looks like a good task for a contribution. Want to work on a PR fixing this? I'll be happy to review and help you land this. |
Yes, I could work on this. What would be the behaviour? Delete all Textures as soon as a source is removed? What is the intention of keeping those textures around anyway? Is it to re-use them, when tiles are re-entering the viewport? |
See the original issue: #591. The reason is to avoid expensive gl.createTexture/deleteTexture calls. Let's find out why the pool grows out of control and fix it so that it's stable. |
Okay, I think I'm understanding it now. So textures are saved in an array indexed by their //...
this.reusableTextures[texture.size] = [texture]; If a texture of this size is already available, the texture is just pushed into that array: textures.push(texture); The retained textures are accessed again through tile.texture = this.map.painter.getTileTexture(img.width); Now const widthTextures = this.reusableTextures[width];
if (widthTextures) {
const textures = widthTextures[height || width];
return textures && textures.length > 0 ? textures.pop() : null;
}
|
Oh rats, this is my fault. Previously we only used square textures and so saved them only by one dimension. (intro'ed in c8cbb9d#diff-d385e592acb94e49c99d265414e2f099R318) Thanks for digging in here @Scarysize — looks like it should be a pretty straightforward PR if you're still up for fixing it! |
@lbud Thanks for chiming in. I will work on a PR today :) |
See #3974 |
Fixed by #3974 😄 |
mapbox-gl-js version: v0.31.0 (also found the issue with 0.26.0)
Steps to Trigger Behavior
jsbin: https://jsbin.com/kojobocuka/edit?js,output
WebGLTexture
object count (should be around 8, if the map wasn't moved/zoomed)Expected Behavior
Textures aren't retained indefinitely for removed sources.
Actual Behavior
Textures are retained for removed sources; as far as I can see they won't be deleted. For long running applications with multiple raster sources & layers being added/removed over time this will lead to increasing memory consumption.
The text was updated successfully, but these errors were encountered: