What’s the analogue of BitmapData.dispose()
for Lime Image?
Lime Image
has an ImageBuffer
behind it which may contain a canvas, Flash BitmapData, uint8array of bytes, etc.
It does not hold any hardware textures – it is software only.
Nulling the reference and letting GC take care of it is generally how its done, but I’m open to a dispose method if there’s a benefit/we have a way of forcibly disposing of those objects
I added image.buffer = null
before image = null
to OpenFL’s BitmapData.dispose
method and it makes sense!
In current versions of OpenFL after runtime resource loading (at least for HTML5 target) you can do something like:
Assets.getBitmapData("some_bitmap.jpg").dispose();
addChild(new Bitmap(Assets.getBitmapData("some_bitmap.jpg")));//you will see the bitmap!
After adding image.buffer = null
this won’t work anymore, and the memory for the disposed image will be freed (so looks like this is a solution for the dilemma concerning graphics here; for sounds assets Sound.close
calls should be added somewhere to the library unloading code).
curious – I wonder why the image.buffer
is kept in memory if the reference is not nulled out