Posts Tagged ‘OutOfMemoryError’

Set the ANT_OPT for flex ant tasks to avoid the error “out of memory” threw by Flex Builder when building a huge project

memory Problem Summary: When I compile a project including thousands MXML and AS files with Flex Ant, I got an error message as below displayed in the Console panel of Flex Builder:

  1. java.lang.OutOfMemoryError: Java heap space
  2. at java.util.HashMap.resize(Unknown Source)
  3. at java.util.HashMap.addEntry(Unknown Source)

It seems that the memory usage of my JRE reaches its limitation — as we know, Flex Builder is running in JRE. Here is a simple way to solve this problem. It‘s just changing the preferences settings of Flex Builder.

Solution Summary: There are two useful arguments of JRE to control the memory usage:

  1. -Xms define the minimum usage of memory by JRE
  2. -Xmx define the maximum usage of memory by JRE

I just set –Xmx to 1024m to satisfy the usage of compiling such huge Flex project.

(more…)