Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Out of memory error in ant

Tags:

java

memory

ant

I am trying to run ant task, however I get the following error:

[javadoc] javadoc: error - java.lang.OutOfMemoryError: Please increase memory.
[javadoc] For example, on the Sun Classic or HotSpot VMs, add the option -J-Xmx
[javadoc] such as -J-Xmx32m.
[javadoc] 1 error
[javadoc] 103 warnings

I have tried googling to find out how I can set this value, but I cannot find it. I have tried

<javadoc maxmemory="256m">

I have tried

export ANT_OPTS=-Xmx256m

but I still get the same exception. I have tried to increase the value to 1024m witouth any success

Update

I solved it. It had nothing to do with little memory. It was an endeless loop in my javadoc generation.

like image 872
Shervin Asgari Avatar asked Jan 06 '11 18:01

Shervin Asgari


People also ask

How do I resolve out of memory exception?

1) An easy way to solve OutOfMemoryError in java is to increase the maximum heap size by using JVM options "-Xmx512M", this will immediately solve your OutOfMemoryError.

What causes out of memory errors?

OutOfMemoryError exception. Usually, this error is thrown when there is insufficient space to allocate an object in the Java heap. In this case, The garbage collector cannot make space available to accommodate a new object, and the heap cannot be expanded further.

What causes Java out of memory error?

A java. lang. OutOfMemoryError is a runtime error in Java which occurs when the Java Virtual Machine (JVM) is unable to allocate an object due to insufficient space in the Java heap. The Java Garbage Collector (GC) cannot free up the space required for a new object, which causes a java.


2 Answers

I solved it.

It had nothing to do with little memory. It was an endeless loop in my javadoc generation.

The correct way of setting more memory for ant is by using export ANT_OPTS=-Xmx256m on *nix.

On Windows follow the usual steps for setting environment variables.

like image 124
Shervin Asgari Avatar answered Oct 19 '22 11:10

Shervin Asgari


The javac ant task has the attribute memoryMaximumSize which you should set to the same value as you would for -Xmx.

<javac memoryMaximumSize="256m" ...>
  ...
</javac>

I should add that this assumes that it is indeed a javac task that's causing the memory overrun.

like image 6
Mike Yockey Avatar answered Oct 19 '22 13:10

Mike Yockey