Why BitmapData.dispose comment out these codes? πŸ€”


Is it OK to simplify it like this?

if(__texture != null)
    __texture = null;


I think most people coming across your post will not try to understand where the code comes from. So you should link the lines of the code like this instead of using an image:

When you dispose the BitmapData, it cleans the RAM memory used for the BitmapData (all buffers set to null), but your linked Texture can still be used:) I think it’s still working that way. I don’t know why it is till in comment, maybe it’s till in beta.

I think it is for a couple reasons:

  1. On multi-threaded platforms, bitmapData.dispose can occur outside of the OpenGL thread, causing trouble
  2. (Perhaps) the idea was to allow garbage collection to run for disposing the textures (which should be supported) rather than relying on an explicit dispose

If calling dispose immediately is giving better results, please let me know and perhaps we could make it platform conditional if it is a matter of threading

I added __texture.dispose to __texture. According to my tests, I can now run normally in C++ target and HTML5 platform. As far as I know, some garbage collectors do not necessarily release the texture actively.