Have you ever suffered from constant pauses in the IDE while using Flex Builder? The default memory and garbage collection choices can, depending on your setup, end up leading to relentless garbage collection that leaves you with the feeling of playing a first person shooter at about ten frames per second. It makes productive development impossible, but fortunately you can almost certainly fix it by tuning the JVM options found in the file flexbuilder.ini in the directory where you installed Flex Builder.
To begin you can check your current environment in Flex Builder by choosing Help -> Product Details -> Configuration Details.
The first thing you might notice is that Flex Builder is running with a JRE 1.5 located in the [jre] directory where Flex Builder is installed, even though as a developer you have the latest 1.6 JRE installed on your system. If you want to run under 1.6, I believe the easiest was to do it is to simply remain the [jre] directory to [this-is-not-a-jre] and restart Flex Builder, which will now run using the default JRE on your system. You can point to a specific JRE on your system, but make sure that Eclipse is actually using that JRE -- see the comments here.
Next you can change the garbage collection and memory settings by editing the file flexbuilder.ini. By default, these settings probably look like this:
-Xms128m
-Xmx512m
-XX:MaxPermSize=256m
-XX:PermSize=64m
Using the Garbage Collection Tuning documentation as your guide, try different settings to improve the responsiveness of the IDE. Since developers' systems, and even the way we use Flex Builder, are different, there is no one choice of settings that is optimal for everyone. However, a few points may hold true:
- Use a larger heap size if you can. More memory is the easiest way to achieve fewer full collections ;-)
- Use a relatively larger tenured collection than the default settings provide.
- A couple of seconds added to compile time is barely noticeable, but constant virtual "screen freezes" while you are typing code or working in the IDE is fatal to your work flow as a developer. Therefore, I have a strong preference for the low pause garbage collector over the throughput collector.
In my case, on an Athlon X2 machine with 2GB of memory I found the following settings give excellent performance without evidence of full collections taking place and, most importantly, have eliminated any hint of constant pauses while using Flex Builder.
-XX:+UseConcMarkSweepGC
-XX:+CMSIncrementalMode
-XX:NewRatio=3
-Xmx640m
Once you have the JVM garbage collection under control, Flex Builder is a joy to use.
Comments