File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes java.lang.OutOfMemoryError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "java.lang.OutOfMemoryError" Watch "java.lang.OutOfMemoryError" New topic


Anand Srinivas

Joined: Dec 30, 2003
Posts: 8
I am new to ANT and while trying to build an application by giving the ant command in the prompt, I am getting an error stating the System is out of resources and it shows java.lang.OutOfMemoryError. Can somebody please explain me why this is happening and how to correct it?

Anand Srinivas
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

What specific target gives you an OutOfMemoryException? Some like javac and javadoc can eat a lot of memory; you might check out the possibility of forking a new jvm for these tasks and allocating more memory to them (see the docs). You might also look out for too many <ant /> and <antcall /> tasks, both are inefficient, since they require reparsing the build file, plus creating seperate instances of Ant's ClassLoader and all Project properties.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Purushoth Thambu
Ranch Hand

Joined: May 24, 2003
Posts: 425
One another issue can be with the Windows ME or 98 editions. If you get this error with simple ant build as well then probably you must increase the size of the command environment.

Windows Explorer -> %ANT_HOME%\bin\ant.bat -> right click > select memory tab > try to increase the size of "Initial environment"
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
Set ANT_OPTS with memory switches. E.g., -Xmx512m
I agree. Here's the link:
subject: java.lang.OutOfMemoryError
It's not a secret anymore!