I use Ant a lot to compile AIR or Flex projects. When it comes to larger projects (especially when you compile multiple modules and libraries) you have to increase the amount of memory Ant is allowed to use. Otherwise you can get an exception like this:
[mxmlc] Loading configuration file PATH_TO_YOUR_SDK/flex_sdk_3.0.2.2095/frameworks/air-config.xml
[mxmlc] Error: PermGen space
[mxmlc] java.lang.OutOfMemoryError: PermGen space
[mxmlc] at java.lang.String.intern(Native Method)
[mxmlc] …
- In Eclipse open menu: Run->External Tools->Open External Tools Dialog…
- Select the build script you want to change on the left
- Select the JRE tab on the right
- Set the following as VM arguments: -Xms768m -Xmx1024m -XX:MaxPermSize=512m
These values work for me but you might want to change it to match your environment and project size.
Update: List of JVM options (via Cornel Creanga)





Sometimes you have to configure also the PermGen memory size – especially if you have a huge number of classes (or JSP files) or you are pushing a lot of string into the constant pool. The parameter is:-XX:MaxPermSize, by default the value is 32mb for HotSpot client and 64 for HotSpot server.
Thanks Cornel! I updated my post with MaxPermSize which also solved one of my issues where I got this PermGen space error.
[...] If you start Ant scripts from Eclipse which is the way I use it all the time you can also run out of memory and I posted a couple of weeks ago how you can change the settings. [...]
[...] If you search for this error you’ll find many blogposts written by utterly frustrated Java developers. It appears to be a dreaded error that is raised when deploying war files to web or application servers. Fortunately, this article pointed me to the right solution for this problem: http://soenkerohde.com/2008/06/change-eclipse-ant-settings-when-you-run-out-of-memory/ [...]
thanks for the solution i was actually looking for this from past a week.
Still fails even after increasing the heap size .
[mxmlc]
[mxmlc] Error: Java heap space
[mxmlc]
[mxmlc] java.lang.OutOfMemoryError: Java heap space
[mxmlc] at java.util.HashMap.(HashMap.java:203)
[mxmlc] at java.util.HashSet.(HashSet.java:86)
[mxmlc] at macromedia.asc.parser.ProgramNode.(ProgramNode.java:64)
[mxmlc] at macromedia.asc.parser.NodeFactory.program(NodeFactory.java:1737)
[mxmlc] at macromedia.asc.parser.Parser.parseProgram(Parser.java:7861)
[mxmlc] at flex2.compiler.as3.Compiler.parse1(Compiler.java:250)
[mxmlc] at flex2.compiler.API.parse1(API.java:2315)
[mxmlc] at flex2.compiler.API.parse1(API.java:2268)
[mxmlc] at flex2.compiler.API.batch2(API.java:369)
[mxmlc] at flex2.compiler.API.batch(API.java:1117)
[mxmlc] at flex2.compiler.API.compile(API.java:1290)
[mxmlc] at flex2.compiler.API.compile(API.java:1210)
[mxmlc] at flex2.tools.Compiler.mxmlc(Compiler.java:275)
[mxmlc] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[mxmlc] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[mxmlc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[mxmlc] at java.lang.reflect.Method.invoke(Method.java:585)
[mxmlc] at flex.ant.FlexTask.executeInProcess(FlexTask.java:283)
[mxmlc] at flex.ant.FlexTask.execute(FlexTask.java:225)
[mxmlc] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[mxmlc] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
[mxmlc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[mxmlc] at java.lang.reflect.Method.invoke(Method.java:585)
[mxmlc] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[mxmlc] at org.apache.tools.ant.Task.perform(Task.java:348)
[mxmlc] at org.apache.tools.ant.Target.execute(Target.java:357)
[mxmlc] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[mxmlc] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
[mxmlc] at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
[mxmlc] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[mxmlc] at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
[mxmlc] at org.apache.tools.ant.Main.runBuild(Main.java:758)
D FAILED
thanks this solved my problem!!!
Thanks!,
This was helped me
Can this method work on Mac?
The VM arguments edit box is un-editable on my Mac(both 10.5 and 10.6).
Yes, I am on a Mac too. So I assume you are missing something else.
On the mac, go to /Application/eclipse/eclipse, Ctrl-Click on eclipse, select “Show Package Contents”, go into directory “Contents/MacOS” and edit eclipse.ini and throw in the parameters. For instance my eclipse.ini is –
-showsplash
org.eclipse.platform
-startup
../../../plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20081125.jar
–launcher.library
../../../plugins/org.eclipse.equinox.launcher.carbon.macosx_1.0.101.R34x_v20080731
-vmargs
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Xms1024m
-Xmx1024m
-XX:MaxPermSize=1024m
-Dosgi.requiredJavaVersion=1.5
-Dorg.eclipse.swt.internal.carbon.smallFonts
Hope this helps! thanks
Excellent solution!!! BEst solution on the internet so far!
Thanks a lot, man!!!!
Thanks a lot for the solution.
Thanks for the solution.U saved my time
Thanks friend. It worked for me !
tyvm mate, it solved my problem with eclipse compiling