4

When creating an ant build script to generate Javadoc, Eclipse is receiving an OutOfMemoryError. The ant build has the -Xmx512m and -Xms512m settings under the JRE tab in the run configuration. This works great for compiling the application. The only trouble is with the Javadoc portion of the build. 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 build script runs I see a 2 step process, Eclipse launches

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

Visual VM shows that this process launches with the Heap memory arguments listed above. This process then spawns the 2nd process "JavaDoc" and the VM arguments are not passed along with it. In VisualVM it can be confirmed that the JavaDoc process has a default -Xms8m value and around a 64m Xmx value before the OOM error is thrown.

Under the Ant preferences in Eclipse I have attempted to add an 'ANT_OPTS' variable to pass the JVM args to JavaDoc. The change did not work.

The build does work if I create a batch file and set the ANT_OPTS values.

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

But creating the batch file is defeating the purpose of allowing me to build everything directly in Eclipse.

I have also tried adding an to the build file, which would hardcode a heap size

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

Any idea how to set the value so my javadoc will spawn with more heap size?

martin clayton
  • 76,436
  • 32
  • 213
  • 198
Sean
  • 7,597
  • 1
  • 24
  • 26

2 Answers2

6

The javadoc task has the attribute maxmemory for specifying this. Allows you to separately tune for this task.

martin clayton
  • 76,436
  • 32
  • 213
  • 198
  • Thanks, that did work, I see my Xmx at the proper value now. Missed that parameter when I was reading the API. will accept answer shortly – Sean Oct 04 '10 at 14:49
0

It is worth noting that apparently you can get an OOME on javadoc for another reason: see that other question : Out of memory error in ant

Community
  • 1
  • 1
Patrice M.
  • 4,209
  • 2
  • 27
  • 36