OSX FlexBuilder Java Heap Space error

Here’s an error I’ve run into from time to time while programming Flex on OSX

	[compc] Error: Java heap space
	[compc] java.lang.OutOfMemoryError: Java heap space	

This error was a real pain in the arse. I found a lot of people having similar issues and they all fixed this problem by setting ANT_OPTS as an environment variable to increase the memory size. This didn’t work for me. I set ANT_OPTS in my .profile, as well as in .MacOSX/environment.plist.  No luck.  I never figured out why the environment variable route didn’t work, but I was able to fix this error within Eclipse.

If you run into this error while running Ant build scripts, try the following steps.

  1. Run Menu > External Tools > Open External Tools Dialog…
  2. Select your Ant build file on the left
  3. Click the JRE tab on the right
  4. Enter “-Xmx640m” in the VM arguments field ( without quotes )
  5. Click Apply, then Run
Flex JVM preferences

Flex JRE preferences

Hopefully this will get you going.