aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes OutOfMemory Exception while building using eclipse compiler 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 "OutOfMemory Exception while building using eclipse compiler" Watch "OutOfMemory Exception while building using eclipse compiler" New topic
Author

OutOfMemory Exception while building using eclipse compiler

Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Hi,
I am using eclipse compiler in ant & building around 8000 files.I am getting OutOfMemory Exception even though i have set the max memory to 1250mb.
The same process though javac compiler runs fine with only 550mb memory.
What other parameter do I need to set so that it compiles through eclipse compiler too.
Thanks.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

What kind of out of memory exception are you getting? There are at least three different types and only one refers to heap memory, so only if you are getting that one will increasing the heap help.

What do you mean by "using eclipse compiler in ant"? That seems backwards to me; do you mean that within Eclipse you are using Ant to do you complies? If so, you could run Ant in a separate JVM.


JBoss In Action
Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Yes I am getting the one which refers to heap.But as I have already told you,I have set the maximum memory to 1250 mb.


What do you mean by "using eclipse compiler in ant"? That seems backwards to me; do you mean that within Eclipse you are using Ant to do you complies?

Regarding above query,I would again say the same.Kindly check the code below :



This is just a sample which I copied from the following link :
IBM help

For using the eclipse compiler ,I used ecj.jar.


If so, you could run Ant in a separate JVM.


Regarding above,I would say that I am setting fork attribute to true.But as I am using eclipse compiler in Ant , I am getting the following information in log


Ignoring fork setting as compiler is neither classic nor modern.


The only possible solution I can think of is setting the compiler to classic or modern so that the Ant runs in a separate JVM.

But don't know how ?
Kindly help.

Thanks for the reply.



Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

What have you done to verify that the heap setting is being used? Exactly what did you do to change the heap size?
Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Actually I am just setting the memorymaximumsize attribute to 1250 mb .
I was going through the Ant docs and found an interesting piece of information.
The memorymaximumsize is used only if the javac is run externally,otherwise ignored.So in my case its getting ignored as fork settings are getting ignored.
Now what to do?
Thanks.

Tirupathi rao
Greenhorn

Joined: Dec 19, 2009
Posts: 4
set your JVM arguments in eclipse before running the ant script (go to ant file try any as provide the JVM arguments), some times eclipse is not considering the JVM arguments through ant script. I did experienced the same , passing the virtual arguments in eclipse -Xmx=512m or -Xmx=1024m, hope it will resolve your issue

Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

To set the heap size for Ant, set the ANT_OPTS env var before running Ant. On Windows:

set ANT_OPTS=-Xmx1024m

By the way, Ant is run from a script (ant_home/bin/ant.bat on Windows, ant_home/bin/ant on Linux). You could even set ANT_OPTS in the script.

Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Thanks Tirupathi , but I am not using eclipse.
Thanks Peter,I have used ANT_OPTS while running checkstyle task,but i didn't know that we can do the same for building files too.
I will try & inform about the result.
Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
Thanks Peter.
Its working now.
Methari Gangadhar
Greenhorn

Joined: May 15, 2011
Posts: 12
Hi,

i am building jar by using ant, and getting the same exception

[ejbc] The system is out of resources.
[ejbc] Consult the following stack trace for details.
[ejbc] java.lang.OutOfMemoryError: Java heap space
[ejbc] Exec failed .. exiting

BUILD FAILED
build.xml:102: Exception while calling weblogic.ejbc. Details: Ejbc reported an error.

i have tried all the scenarios what Peter has specified. like
from command prompt set ANT_OPTS=-Xmx1024m and modified ant.bat file adding "set ANT_OPTS=-Xmx1024m" still the error is not yet resolved. i am giving patch of my build.xml file where am getting error.


<target name="aurorajar">

<ejbjar srcdir="${streamcoreclass}\aurora,${streamcoreclass}\common" descriptordir="${streamcoresrc}\aurora\${aurorapackage}\META-INF" basejarname="aurora">
<dtd publicId="-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" location="${configbase}/ejb-jar_1_1.dtd"/>
<include name="ejb-jar.xml"/>
<support dir="${streamcoreclass}\aurora">
<include name="${aurorapackage}\"/>
</support>
<support dir="${streamcoreclass}\common">
<include name="${commonpackage}\"/>
</support>
<weblogic destdir="${build}">
<classpath refid="common.classpath"/>
<classpath refid="third.party.classpath"/>
</weblogic>
</ejbjar>
</target>

getting error at the bold text .
can you please suggest, am trying till morning.

Thanks,
Gangadhar
Max White
Ranch Hand

Joined: Jun 28, 2008
Posts: 85
add the below line in ant.bat as the first line

set ANT_OPTS=-Xms512m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=256m
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

First, verify that that Antis running with the new memory options.

If it is, how big is the app you are compiling?
Methari Gangadhar
Greenhorn

Joined: May 15, 2011
Posts: 12
hi Max,

i have specified below line in ant.bat file, even i increaed 512 to 1024 still same problem

set ANT_OPTS=-Xms512m -Xmx512m -XX:PermSize=256m -XX:MaxPermSize=256m

Hi Peter,

the ant is running at new memory values, my application is having 1060 source files.

Thanks,
Gangadhar
Methari Gangadhar
Greenhorn

Joined: May 15, 2011
Posts: 12
Hi,

Thanks for your help Max and Peter,

I got resolved the problem by changing the build.xml file

<weblogic destdir="${build}" jvmargs="-Xmx128m">
<classpath refid="common.classpath"/>
<classpath refid="third.party.classpath"/>
</weblogic>

i have added just that jvmargs it solved my problem.

Thanks for your help.

Thanks,
Gangadhar
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    7

It always helps to know which JVM is running out of heap space and giving that JVM a larger heap. Glad you are up and running.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OutOfMemory Exception while building using eclipse compiler