Managing graphics memory in AIR for TV apps

And here’s one more design consideration for AIR for TV application development…

This one continues the discussion from the blog entry called Using Graphics Hardware Acceleration in AIR for TV Apps.

To perform the accelerated graphics operations, hardware accelerators use special graphics memory. If your
application uses all the graphics memory, the application runs more slowly because AIR for TV reverts to using
software for the graphics operations.

To manage your application’s use of graphics memory:

  • When you are done using an image or other bitmap data, release its associated graphics memory. To do so, call the dispose() method of the bitmapData property of the Bitmap object. For example:


Note: Releasing the reference to the BitmapData object does not immediately free the graphics memory. The runtime’s garbage collector eventually frees the graphics memory, but calling dispose() gives your application more control.

  • Use PerfMaster Deluxe, an AIR application that Adobe provides, to better understand the impact of hardware graphics acceleration on your target device. This application shows the frames per second to execute various operations. Use PerfMaster Deluxe to compare different implementations of the same operation.  For example, compare moving a bitmap image versus moving a vector image. PerfMaster Deluxe is available with the Adobe® AIR® for TV MAX 2010 Hardware Developer Kit, and will soon be available at Flash Platform so you can use it with other devices, too.

And don’t forget: Do not keep bitmap objects, or any objects, on the display list when they are not visible. Whether software or hardware renders a display object, rendering it when it is not visible needlessly uses resources to render the object. If you have a good reason to hold onto a display object when it is not visible, remove the object from the display list. This best practice applies not only for AIR for TV apps, but AIR apps and Flash Player apps on all devices (mobile, desktop, tablet, and TVs).

One Response to Managing graphics memory in AIR for TV apps

  1. Jackie Levy says:

    I want to clarify/correct the last paragraph in this blog post about handling display objects that are not visible.

    In AIR or Flash Player, on any device, to make a display object invisible, set the object’s visible property to false. Then, the object is still on the display list, but the runtime does not render or display it. This technique is useful for objects that frequently come and go from view, because it incurs only a little processing overhead.

    However, setting the visible property to false does not release any of the object’s resources. Therefore, when you are done displaying an object, or at least done with it for a long time, remove the object from the display list. Also, set all references to the object to null. These actions allow the garbage collector to release the object’s resources.