While doing an ant build sometimes it happen that a user may get the OutOfMemoryError. This is mainly because the heap size of Java JVM is less. This heap size can be increased. But caution that the heap size of java JVM which is running through Ant has to be increased and not of the JVM of Jdk 1.x .
To increase the heap size of JVM in ant ,open the file ant.cmd present in Ant/bin folder.
Change following line
“%_JAVACMD%” %ANT_OPTS% -classpath “%ANT_HOME%\lib\ant-launcher.jar” “-Dant.home=%ANT_HOME%” org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp “%CLASSPATH%” %ANT_CMD_LINE_ARGS%
“%_JAVACMD%” –Xms512m -Xmx1024m %ANT_OPTS% -classpath “%ANT_HOME%\lib\ant-launcher.jar” “-Dant.home=%ANT_HOME%” org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp “%CLASSPATH%” %ANT_CMD_LINE_ARGS%
This problem also comes when you build your project with Maven , here is couple of link when helps to solve OutOfMemory and increase heap in Maven
How to increase heap size in Maven
How to solve outofMEmoryError in Java