-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
BitmapData in Sprites is never freed from PIXI.CanvasPool when destroyed #2261
Comments
I thought it was about the baseTextures not clearing up correctly on sprites when I found out that when I create sprites with group.create(0,0,BMD) and removing them with group.removeAll(true,true) does not actually free them. Checked with webgl inspector.. Should try to destroy those bitmapdatas also if that helps.. This should be fixed asap. :) |
what about adding this to the destroy.js? |
I'm not sure there's a "catch all" fix for this. Take the following example:
This would then invalidate sprite2's texture. You could say that on a State swap this wouldn't matter, but I've some games where I precalc a texture in my boot state and store it in the cache, so in those cases it would destroy the original as well. I honestly think this needs flagging in the docs and handling in userland code. |
…thod: `destroyTexture`. This boolean (which is false by default) controls if the BaseTexture of the Game Object should be destroyed or not. This is extremely useful in situations where you've got a lot of dynamic assets you no longer need, such as textures created from BitmapDatas. You must set the `destroyTexture` argument yourself. This can be done in a custom Game Object destroy method or as part of your state shutdown (#2261)
There, I'm quite happy with the solution offered in the latest commit. That, combined with the |
If you create a sprite from a BitmapData like such:
When the sprite is destroyed, the BitmapData will not be removed from PIXI.CanvasPool.
In my case I change states quite often and one of them uses many BitmapData-sprites. This can easily consume 10-15mb of memory each time the state is started, which is never freed.
There is, possibly, a note about this already:
https://github.com/photonstorm/phaser/blob/master/src/pixi/display/DisplayObject.js#L687
Which is called from here:
https://github.com/photonstorm/phaser/blob/master/src/gameobjects/components/Destroy.js#L142
The BitmapData has code to remove it in its destroy function. But this function is never called.
https://github.com/photonstorm/phaser/blob/c9c85330ab60547b39ba4c9400c258ed7fb2a317/src/gameobjects/BitmapData.js#L1814
The text was updated successfully, but these errors were encountered: