When preparing a Flex project for deployment, always make sure to export a release build. I think most people know about this feature of FlexBuilder, but I’m not sure everyone is aware of just how important it is. The SWF that is generated when you run or debug your project contains a lot of extra byte code used for debugging and profiling your content.
This extra byte code has a very obvious effect on the size of your SWF (adding over 35% in some cases). It also has a less immediately obvious (but no less significant) effect on the performance of your application. In one example here at gskinner.com, a 980kb SWF was reduced to 675kb, and some performance intensive code ran over 2.5x faster in the release build than in the debug version.
Never deploy a project without exporting a release build, and be sure to test a release build if you are experiencing problems with file size, performance, or memory utilization.
Good point, I find it actually month ago, from Flex devnet: http://link.brightcove.com/services/player/bcpid1681730258?bctid=1844687190
Does anybody know which mxmlc arguments are passed when Flex Builder performs a Release Build? Sounds like my Deploy ANT Task might need updating! 🙂
I add debug=false and optimize=true to the compiler options which seems to do the same thing. This also has the advantage of not needing to remember to export a release build as I already am.
Jonny – I believe the mxmlc arguments are “-optimize” and “-debug”, though there could be more.
Hi Grant,
And one important step further in getting published SWF sizes down is using the Framework caching too!
One fellowâs positive experience here:
http://tech.groups.yahoo.com/group/flexcoders/message/108149
The how to in the docs here:
http://livedocs.adobe.com/flex/3/html/rsl_09.html
Also a Flexcoders thread on this topic here (follow threads at the bottom of this page):
http://www.mail-archive.com/flexcoders@yahoogroups.com/msg103723.html
Happy Flexing!
g
@greg h – just be careful when combining rsls with module loading. there’s a pretty fundamental defect still outstanding: http://bugs.adobe.com/jira/browse/SDK-14669
Great tip, i didnt know that.
Ales
Yeah Adobe should have made more buzz about this when introducing FlexBuilder 3. I took me a hile to figure out why my swfs were some much bigger coming out of FB 3 than out of 2. My question is way have the run button if it does the same thing as debug.
Apart from this all, use ‘Runtime shared library (RSL)’ for a exported project.
project -> properties -> Flex build path -> Library Path -> Framework linkage.
The main .swf file size will reduced dramatically and hence load faster.
Is there any way to set the compilers command line options based on Relese or Debug builds from within Flash Builder 4? Or from a config file? This would be useful for conditional compile info.
Also remember, that compiling in debug mode will put Your source code to swf file…