Do I have to manually dispose bitmaps when using tilesheet?

Hi, I have a big memory leak and I cant find it. I can only imagine it could be the bitmaps not being dispose. When I delete it the app just goes black instead of crashing, maybe another bug.
So in conclusion do I have to dispose the bitmaps?

In Legacy there was bitmapData.dumpBits(); to remove the bitmap from the memory but you were still able to use it in tilesheet (because the bitmap was loaded to the GPU memory). Using this trick I saved 90% of memory in my game !!! (from 1Go to 100Mo of memory)

Is there anything similar in Next ? I’m willing to find a similar way to purge the memory.

Thank you loudo, thats a smart trick, the function im using is dispose but dont know how safe is to dispose at the start, didnt found an inmediat upload to the vídeo card. I found that if you let mouseEnable to true(the default state) the image is almost duplicated once you click on the tilesheet draw. I guess it creates another instance to calculate the are anf stuff.

I had a similar issue, every time I was loading a level, all the assets, like background and stuff were being cached, and after a few levels, the memory usage was so high that on mobile devices the game would crash.
I solved it by clearing all level specific assets from cache:

openfl.Assets.cache.clear('LevelBackgrounds');

This will remove from cache all assets stored under LevelBackgrounds, as for example LevelBackgrounds/Level1.jpg.

1 Like