Minimize CPU usage in Flash and Flex

Comments Off on Minimize CPU usage in Flash and Flex

This article highlights a few interesting points to consider, when you want to minimize the resources that a flash/flex application consumes at runtime. The benefit of that is not only the improved user experience, but also the extra power you can use, and not waste.

I’m going to summarize here the points, ordering them by how often you would face during development, and I invite you to go through the entire article for a more in-depth picture.

  • Freezing and unfreezing objects. The secret here is to to be very cautious with the objects that are not visible, or not needed anymore.  There is also a method in the Loader class, unloadAndStop(). This method can enforce the Garbage Collector to run on the child SWF objects, if you call it with unloadAndStop( true ).
  • Timers versus ENTER_FRAME events What is important here is to avoid using ENTER_FRAME events, and minimize as much as possible the usages of Timer objects.
  • Activate and Deactivate Events. These are used to detect  background inactivity, and detect when Flash Player has lost the focus. When Flash content looses focus it’s worthy to decrease the frame-rate, and maybe cancel some background operations.
  • Mouse interactions. This can be CPU-intensive, especially when the object tree is rich. Flash Player enables you to disable some UI components to respond to mouse event, using myUIComponent.mouseEnabled=false;
  • Animations. Use them, but be aware that currently they are executed by the CPU, not the GPU. In the near future, this processing would move to GPU, easing the CPU, but until then, be careful with the rendering.
  • Built-in Flash Player 10.1 enhancements. These are interesting and it’s good to be aware of.

No Comments

No comments yet.

Sorry, the comment form is closed at this time.

Comments RSS Feed