Mac Ant Build – Error: PermGen space

This is worthy of a post because it took me a while to figure it out.

I created a fairly large Ant build script that kicks off builds for a project’s dependencies and it was working great until I added a few more things. It started failing with this:

[compc] Loading configuration file /Applications/Adobe Flash Builder 4/sdks/4.1.0/frameworks/flex-config.xml
[compc] Error: PermGen space

I’m not a hard core Java guy but I figured this had something to do with the Java Virtual Machine running out of memory. So after digging a bit and trying a few different things the solution I came up with was this:

export ANT_OPTS=-XX:MaxPermSize=512m

Try it on the command line first. If that works for you, you might want to add it to your .bash_profile. Once I added that, my build script was able to complete.