Increase memory of Eclipse Ant Runner


I am running the Eclipse ant runner from command line in the following way:

set LAUNCHER=xx\xx\org.eclipse.equinox.launcher_1.1.3.0.jar
xx\xx\java.exe -jar %LAUNCHER% -application org.eclipse.ant.core.antRunner -buildfile build.xml

I am facing OutOfMemory errors in the heap space. Adding -vmargs -Xmx512m to the command line or and changing the properties of my eclipse installation eclipse.ini file didn’t fixed the issue.

In order to be sure that the vmargs are taken into account I simply wrote the folowing task:

public class DisplayTask extends Task {
@Override
public void execute() throws BuildException {
System.out.println(Runtime.getRuntime().maxMemory() / 1000000);
}
}

and just launch it in my build.xml (using taskedf to define the task). The output is always 66 whatever I put in -vmargs -Xmx ….
After several tests I got the solution by adding -Xmx512m  only (without -vmargs) option just after the java.exe as folowing:

xx\xx\java.exe -Xmx512m -jar %LAUNCHER% -application org.eclipse.ant.core.antRunner -buildfile build.xml

Conclusion: the ant runner application doesn’t read neither the -vmargs command line options nor the eclipse.ini file options. Thus the only solution to increase memory for it is to directly pass the option to the Java virtual machine.

Advertisements