How to increase memory for Ant "Javadoc" task?

When creating an ant build script to generate a Javadoc, Eclipse gets an OutOfMemoryError. The ant construct has the -Xmx512m and -Xms512m on the JRE tab in the startup configuration. This is great for compiling an application. The only problem with the Javadoc build part. Here is the build.xml file

 <target name="JavaDoc" description="Create Javadocs"> <javadoc destdir="c:/javadoc" windowtitle="My API"> <classpath refid="application.classpath" /> <packageset dir="Source"> <include name="**" /> </packageset> </javadoc> </target> 

When the script is building, I see a two-step process, Eclipse starts

 org.eclipse.ant.internal.ui.antsupport.InternalAntRunner 

Visual VM shows that this process starts with the heap memory arguments listed above. This process then starts the second "JavaDoc" process, and VM arguments are not passed along with it. In VisualVM, you can confirm that the JavaDoc process has a default value of -Xms8m and about 64m Xmx before the OOM error is reset.

In the ant settings in Eclipse, I tried to add the ANT_OPTS variable to pass JVM arguments to JavaDoc. The change did not work.

The assembly works if I create a batch file and set the values ​​ANT_OPTS.

 set ANT_OPTS=-Xms512m -Xmx512m ant -file C:\myApp\build.xml JavaDoc 

But creating a batch file leads to victory in a goal that allows me to build everything directly in Eclipse.

I also tried adding a file to the assembly file, which will hard-set the heap size

 <arg value="ANT_OPTS=-Xms512m -Xmx512m" /> 

Any idea how to set the value so that my javadoc appears with a large heap size?

+4
source share
2 answers

The javadoc task has a maxmemory attribute to indicate this. Allows you to individually configure for this task.

+6
source

It is worth noting that, apparently, you can get OOME on javadoc for another reason: see another question: Ant memory error

0
source

All Articles