BitmapData don't destroy

I’m dynamically creating textureAtlas based on bitmapdata.canvas. When the level is over i destroy that bitmapdata and also remove textureAtlas via this.game.cache.getBaseTexture("textureAtlasName").destroy();.
But memory is still growing up. What can it be?

Maybe destroy() doesn’t supress it from the cache and maybe there is another function to do it

I also use
this.game.cache.removeTextureAtlas("puzzleAtlas");
And i don’t know why it’s still in memory.
Funny moment: When i change state from Level to Menu last texture atlas clears from memory. but if i change state from Level to Level(restarting it) then i have stacked textureatlases in memory

If you use destroy in one of the predefined methods in a state it will destroy the Game Object. It means removes it from its parent group, destroys the input, event and animation handlers if present
and nulls its reference to game , freeing it up for garbage collection.
According to the documentation

There are some predefined methods in Phaser CE
init
preload
loadUpdate
loadRender
create
update
preRender
render
resize
paused
resumed
pauseUpdate
shutdown

Maybe the reference of the game object is destroyed specifically in one of these methods

Thanks for you answer, but the question is still why they are not disappear on Level to Level, just on Level to Menu. I try to keep destroy method on every my class and clean up everything. But may be i need to recheck all my classes on correct destruction.

1 Like