Tuesday, May 11, 2010

Flex Builder 3: Optimizing Flex Builder Performance

Many time while developing large project using Flex Builder, performance of IDE is comparatively slow which always leads to frustration. While finding solution for this issue I came across few Eclipse environment tweaks, which along with certain workflow best practices improves performance of IDE.

Workflow best practice

  • Turn-off Build Automatically: This feature is best suited for small project or for prototypes, as it save developers from pressing Run button again and again. Developer just need to refresh browser after saving changes. But in case when project size is large, having flex builder to recompile for every small changes save is very taxing.
  • Having only required project open: Whenever Flex Builder create a build or perform copy-paste/rename operation, it refreshes entire document tree for every open project. Time taken for updating document tree of Flex Builder is directly proportionate to number of open project.
  • Don't embed too many assets: Project compilation time and size of project SWF file is directly proportionate to number of assets embedded for project. There are two ways to resolve this issues:
    1. Use resource bundled for embedded assets
    2. Assets that need to be embedded for the application can be embedded into a module, which can be then loaded into application at runtime.
  • Turn-off Copy non-embedded file to output folder: This option is available under Flex Compiler option of Properties panel. If turn-on Flex Builder will copy all files including one which will be never referenced into build folder of application. This action is waste of compilation time.
  • Clean your project: When this command is executed for project Flex Builder will reset html-template folder of project along with erasing all the files in debug folder and cleaning cache code i.e., restarting entire project afresh.

Eclipse environment tweaks

Eclipse IDE has several optional command line argument that can used to improve IDE performance. All command line argument are executed when IDE is launched. This command are:

  • -clean: This argument flushes the registry cache and clear Eclipse setting and framework.
  • -refresh: This argument instruct Eclipse to refresh the file list in local workspace. This argument is useful if many file changes has occurred between Flex startups or if Flex has shutdown unexpectedly.
  • -showlocation: This argument displays current location of the workspace in window title bar.
  • -vmargs: This argument helps to customize the operation of Java Virtual Machine [JVM] that is use to run Eclipse. The following parameters associated with vmargs argument are used for tweaking memory allocation for JVM
    By default Eclipse will be allocated 256MB of Java heap memory. This value can be modify/increase/decrease by assigning appropriate values. -xmsparameter determine minimum assigned memory. -xmxparameter determine maximum assigned memory. It is advisable to allocate same value for xms and xmx to avoid memory resizing.
  • -XX:MinPermSize=[memory]
    The above arguments are use to set JVM's PermSpace, which is the area of memory use to store data structure and class information in real-time. By default Eclipse will be allocated 64MB of memory space. Setting MinPermSize and MaxPermSize to 128MB or 256MB can solve OutOfMemoryException.

    Note: Sometime by allocating memory for JVM much more than allowed/supported by system, system will throw an error. In such case decrement the assign value a little and try again.

    As recommended, assign as much memory as your system will allow to JVM, this will enable your workbench to run as efficiently as possible.

Above Eclipse environment tweaks can be achieve by modifying FlexBuilder.ini or by using the arguments in shortcut for launching the Flex builder.

Under normal circumstances target field under shortcut panel of Flex Builder will look like

Target "C:\Program Files\Adobe\Flex Builder 3\FlexBuilder.exe"

In case if you want to display location of current project and increase memory allocated to JVM to 512MB thentarget field under shortcut panel of Flex Builder will look like

Target "C:\Program Files\Adobe\Flex Builder 3\FlexBuilder.exe" -showlocation -vmargs -Xmx512m -Xms512m

When you open the FlexBuilder.ini file, it looks like

1 -vmargs
2 -Xms256m
3 -Xmx256m
4 -XX:MaxPermSize=256m
5 -XX:PermSize=64m
6 -Djava.net.preferIPv4Stack=true

Add clean, refresh or showlocation argument prior to vmargs argument in FlexBuilder.ini file. In case if you want to display location of current project then FlexBuilder.ini file after update will look like

1 -showlocation
2 -vmargs
3 -Xms256m
4 -Xmx256m
5 -XX:MaxPermSize=256m
6 -XX:PermSize=64m
7 -Djava.net.preferIPv4Stack=true

The FlexBuilder.ini file should be in your Flex Builder install folder.

No comments:

Post a Comment