Wednesday, December 1, 2010

Flex - Speed Up Performance

Here is some tips for speed up flex application.

1. Always use weak reference when and event is initialize as well as used removefromstage event and in that event clear all object and listener and use System.gc() for release memory.

2. Maximum use ActionScript Class (.as class) instead of used direct component of vbox , canvas etc... so when we need to release memory we easily remove this object from memory.

3. Code Optimization - Create common single instance class for same function of different location as well as try minimize function and create one global function for similar functionality.

4. If application is medium / large then use module and also give separate style sheet on each module and set minimum connection with Main application of this module. When module is no need in memory then remove module and clear all it's object as well as used System.gc() for release memory.

5. Some tips for release memory :

i) When UrlLoader , File , FileReference , ArrayCollection used then after finish of used close / stop / null / finished / removeall this object which is internally given in this object.

ii) Used CatchAsBitmap when object used repeated many times.

iii) Minimum used of BindingUtility and don't forget to clear ChangeWatcher object which is generated when BindingUtility is set.

iv) Possible then separate used .as of each mxml file as well as maximum create object dynamic so after finishing his work you can remove it from parent.

v) Maximum use vector design which are generated in flash or in flash buider 4's skinn or used graphics utility.


6) Try to minimum image load in to your system when any module/object is currently running if it's required to open many high resolution / big sized imaged then load low resolution/ low size version of this image in front so then occupy less memory.

7)Last one use profiler so you know each object's memory size and manage your coding according to size.