AS3 Memory Conservation (Loaders/BitmapDatas/Bitmaps/Sprites)

Posted by rinogo on Stack Overflow See other posts from Stack Overflow or by rinogo
Published on 2009-11-05T01:40:03Z Indexed on 2010/06/06 20:52 UTC
Read the original article Hit count: 354

Filed under:
|
|
|

I'm working on reducing the memory requirements of my AS3 app. I understand that once there are no remaining references to an object, it is flagged as being a candidate for garbage collection.

Is it even worth it to try to remove references to Loaders that are no longer actively in use? My first thought is that it is not worth it.

Here's why: My Sprites need perpetual references to the Bitmaps they display (since the Sprites are always visible in my app). So, the Bitmaps cannot be garbage collected. The Bitmaps rely upon BitmapData objects for their data, so we can't get rid of them. (Up until this point it's all pretty straightforward).

Here's where I'm unsure of what's going on: Does a BitmapData have a reference to the data loaded by the Loader? In other words, is BitmapData essentially just a wrapper that has a reference to loader.content, or is the data copied from loader.content to BitmapData?

If a reference is maintained, then I don't get anything by garbage collecting my loaders...

Thoughts?

© Stack Overflow or respective owner

Related posts about flex

Related posts about flash