Thursday, September 04, 2008

Increasing Memory for Ant

I had an issue today with the javac Ant task running out of memory when compiling a project (~800 files) under Java 6 on the Mac. It was fine under the default Java 5 compiler on the Mac, and it was fine under Java 6 on the PC. Initially, I set memoryMaximumSize on the javac task, which also required that fork be set.
This was OK, but since this was specific to compiling on the Mac, I figured the solution should be specific to my environment on the Mac. After looking at the source of the ant script, I realized that the ANT_OPTS variable could be set to contain an option (-Xmx512m) for the JRE running Ant, and that ANT_OPTS could be set from either ~/.antrc or ~/.ant/ant.conf. So, I created ~/.antrc with one line: ANT_OPTS=-DXmx512m.
(Update: oops, that should be ANT_OPTS=-Xmx512m)
And it worked perfectly, of course - so simple it had to work.

enjoy,
Charles.

3 comments:

cmodien said...

Instead of ANT_OPTS=-DXmx512m it should be ANT_OPTS=-Xmx512m

Take out the D

Charles Anderson said...

yeah - thanks. I just updated the post. That's what I get for not copying and pasting directly.

Captblarney said...

| Take out the D

Thats what she said. But seriously, thanks for this