java.lang.OutOfMemoryError while doing ant build?


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%