Change Eclipse Ant settings when you run out of memory

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)

29 comments to Change Eclipse Ant settings when you run out of memory

  • 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: […]

  • Jithendra

    thanks for the solution i was actually looking for this from past a week. :-)

  • Still fails even after increasing the heap size .

    [mxmlc] Error: Java heap space
    [mxmlc] java.lang.OutOfMemoryError: Java heap space
    [mxmlc] at java.util.HashMap.(
    [mxmlc] at java.util.HashSet.(
    [mxmlc] at macromedia.asc.parser.ProgramNode.(
    [mxmlc] at macromedia.asc.parser.NodeFactory.program(
    [mxmlc] at macromedia.asc.parser.Parser.parseProgram(
    [mxmlc] at flex2.compiler.as3.Compiler.parse1(
    [mxmlc] at flex2.compiler.API.parse1(
    [mxmlc] at flex2.compiler.API.parse1(
    [mxmlc] at flex2.compiler.API.batch2(
    [mxmlc] at flex2.compiler.API.batch(
    [mxmlc] at flex2.compiler.API.compile(
    [mxmlc] at flex2.compiler.API.compile(
    [mxmlc] at
    [mxmlc] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [mxmlc] at sun.reflect.NativeMethodAccessorImpl.invoke(
    [mxmlc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    [mxmlc] at java.lang.reflect.Method.invoke(
    [mxmlc] at flex.ant.FlexTask.executeInProcess(
    [mxmlc] at flex.ant.FlexTask.execute(
    [mxmlc] at
    [mxmlc] at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
    [mxmlc] at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    [mxmlc] at java.lang.reflect.Method.invoke(
    [mxmlc] at
    [mxmlc] at
    [mxmlc] at
    [mxmlc] at
    [mxmlc] at
    [mxmlc] at
    [mxmlc] at
    [mxmlc] at
    [mxmlc] at


  • Ferzerkerx

    thanks this solved my problem!!!

  • Nuwan

    This was helped me :)

  • Ramer

    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.

  • Sai

    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 —

    Hope this helps! thanks

  • Teodor GUTAN

    Excellent solution!!! BEst solution on the internet so far!

    Thanks a lot, man!!!!

  • Manish Thakur

    Thanks a lot for the solution.

  • Ravi

    Thanks for the solution.U saved my time

  • Sher

    Thanks friend. It worked for me !

  • tyvm mate, it solved my problem with eclipse compiling :)

  • Aschwin Wester


    The term ‘PermGen space’ referred indeed to -XX:MaxPermSize=512m
    I could not find the eclipse location to change the setting.
    This was the solution, so thanks

  • […] muss man etwas ausprobieren; mein Wert weicht von der Quelle ab, und die nutzt andere Einstellungen als ihre […]

  • Tushar

    Hi Guys,

    I added following params in eclipse.ini file and also added to class Arguments, however still getting error-
    “java.lang.OutOfMemoryError: PermGen space”

    Can some one tell me the permanent solution to this issue?


  • dll

    Thanks worked perfectly, we’re running Zelix Klass Master to obfuscate our web app, and I’ve been running into java heap errors when it comes to obfuscating the classes. Your steps worked perfectly, it’s really not trivial to find in Eclipse! Thanks again!

  • Utkarsh Chachad

    What must i do if i am running the ant task from command line & not from Eclipse??

  • Under OSX add this to your ~/.profile: export ANT_OPTS=”-Xms512m -Xmx512m”

  • Utkarsh Chachad

    Sorry I did not get u … I don’t have any knowledge or prior exp of flex command line builds. Can you please elaborate? Where do I find OSX & where exactly do i type “export ANT_OPTS=”-Xms512m -Xmx512m”

  • Utkarsh Chachad

    Also i am running this for windows so if your are talking in terms of linux then its no use. Thnx

  • Thanks mate!

    It solved my headache.



  • chathuraka

    thanks for sharing.. had this issue for a while

  • Karthik

    Sorry to resurrect a dead post. But this solution saved me a lotta time.

    Karthik J

  • NagRock


  • Billy Ding

    Thanks. It works like a charm.