tags:

views:

167

answers:

2

Hi,

I am using ant for building my projects, This project needs more memory then default JVM size, So I have added following line of code in the build.xml file.

<!-- setting up this value as project need this much memory to compile.-->
<property environment="env" />
<property name="env.ANT_OPTS" value="-Xms1024m -Xmx204888m"  />

But above line of code does not seems to have any effect as I am still getting the heap size problem. So I have decided to use a batch script for launching the build. The line of code in the given batch file is below

set ANT_OPTS=-Xms512m -Xmx778m
ant -f agora-build.xml

This batch script successfully launch and executes the ant script. But this is not what I am looking for. Is there a way exists, so that I can setup this argument in the ant script itself?

What should i do?

Thanks, VSD

+1  A: 

If you are running the Ant script in Eclipse

Right Click -> Run As -> External Tools Configuration

(Add the build if it isn't there already)

Go to the JRE tab and add the Xms and Xmx arguments to the VM arguments section.

*edit: "-Xmx204888m" I hope 2 of those 8's are typo's

Sean
No sir, I am running it form command prompt. This script supposed to be running in the command line only. Thanks
Vijay Shanker
Your script above does look right. Did you try setting the variable (ANT_OPTS) in the Environment Variables in windows? Should work the same as you typed it above in the script, but worth the shot.
Sean
What about using the "Running Ant via Java" optionhttp://ant.apache.org/manual/running.html#viajava
Sean
As i have written above, It works in a `batch` script. It must be some thing missing from my side.
Vijay Shanker
Yes this link seems to be answer for my query.
Vijay Shanker
+4  A: 

If you set the option in the build script, the JVM is already up and configured; the only way to set JVM-level options from within a build file is to have Ant spawn another JVM (using the java task as a launcher, or the ant task).

You can also set ANT_OPTS as an environment variable; that will affect all Ant builds you run and pass the provided options to the JVM that Ant runs in.

mlschechter