• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Within Eclipse - ant javac task and OutOfMemory error.

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a little baffled by what I'm seeing, and don't really know how to get around it. I found a thread here and there that mentioned it, but it was dealing with Ant not specifically running from within Eclipse Indigo (the non-EE version).

I have an Ant build file, and am doing a pretty simple compile, but it has a few excludes. It looks something like this:



source.dir, by the way, is set to . (single dot, ie: current directory)

SOMETIMES it works, but often it fails with the following message:
[javac] The system is out of resources.
[javac] Consult the following stack trace for details.
[javac] java.lang.OutOfMemoryError: Java heap space
[javac] at com.sun.tools.javac.tree.TreeMaker.Unary(TreeMaker.java:353)
[javac] at com.sun.tools.javac.parser.Parser.term3(Parser.java:864)
[javac] at com.sun.tools.javac.parser.Parser.term2(Parser.java:686)
[javac] at com.sun.tools.javac.parser.Parser.term1(Parser.java:657)
[javac] at com.sun.tools.javac.parser.Parser.term(Parser.java:613)
[javac] at com.sun.tools.javac.parser.Parser.term(Parser.java:595)
[javac] at com.sun.tools.javac.parser.Parser.expression(Parser.java:585)
[javac] at com.sun.tools.javac.parser.Parser.parExpression(Parser.java:1453)
[javac] at com.sun.tools.javac.parser.Parser.statement(Parser.java:1609)
[javac] at com.sun.tools.javac.parser.Parser.blockStatements(Parser.java:1499)
[javac] at com.sun.tools.javac.parser.Parser.block(Parser.java:1462)
[javac] at com.sun.tools.javac.parser.Parser.block(Parser.java:1476)
[javac] at com.sun.tools.javac.parser.Parser.statement(Parser.java:1606)
[javac] at com.sun.tools.javac.parser.Parser.statement(Parser.java:1610)
[javac] at com.sun.tools.javac.parser.Parser.blockStatements(Parser.java:1499)
[javac] at com.sun.tools.javac.parser.Parser.block(Parser.java:1462)
[javac] at com.sun.tools.javac.parser.Parser.block(Parser.java:1476)
[javac] at com.sun.tools.javac.parser.Parser.statement(Parser.java:1606)
[javac] at com.sun.tools.javac.parser.Parser.statement(Parser.java:1646)
[javac] at com.sun.tools.javac.parser.Parser.blockStatements(Parser.java:1499)
[javac] at com.sun.tools.javac.parser.Parser.block(Parser.java:1462)
[javac] at com.sun.tools.javac.parser.Parser.block(Parser.java:1476)
[javac] at com.sun.tools.javac.parser.Parser.statement(Parser.java:1660)
[javac] at com.sun.tools.javac.parser.Parser.blockStatements(Parser.java:1499)
[javac] at com.sun.tools.javac.parser.Parser.block(Parser.java:1462)
[javac] at com.sun.tools.javac.parser.Parser.block(Parser.java:1476)
[javac] at com.sun.tools.javac.parser.Parser.methodDeclaratorRest(Parser.java:2532)
[javac] at com.sun.tools.javac.parser.Parser.classOrInterfaceBodyDeclaration(Parser.java:2481)
[javac] at com.sun.tools.javac.parser.Parser.classOrInterfaceBody(Parser.java:2408)
[javac] at com.sun.tools.javac.parser.Parser.classDeclaration(Parser.java:2253)
[javac] at com.sun.tools.javac.parser.Parser.classOrInterfaceOrEnumDeclaration(Parser.java:2191)
[javac] at com.sun.tools.javac.parser.Parser.typeDeclaration(Parser.java:2180)

BUILD FAILED

Oddly, when it does fail, I get warnings about non-UTF-8 characters, but when it succeeds, I get no such warnings.
My eclipse.ini looks as follows (only the last 2 lines are changed from what was already there)


So, I've tried changing my javac line to read as follows


Alternately I've tried saying fork="true" instead... both give me the same result - I get the following message:
[echo] Running the Main Build Task
[javac] Compiling 2584 source files
[javac] javac: invalid flag: E:\myprojectdir
[javac] Usage: javac <options> <source files>
[javac] use -help for a list of possible options

BUILD FAILED

By the way, E:\myprojectdir is the directory wherein my project exists, as well as where the build.xml files exist. I didn't set it up this way, but I'm not allowed to change it. The .class files are supposed to wind up in the directories where their corresponding .java files exist.

So, I don't know why setting the fork value causes the failure that it does. Is there any way around the out of heap space error, preferably via changes within the build.xml file itself? Running Ant separately outside of Eclipse is not an option for me, either, and I don't know if that'll change any time soon or not.

Also, anyone know why the fork option gives me the odd results that it does?

Thanks. As you might guess, I'm rather new to dealing with Ant on anything more than the simplest level.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should try increasing the heap size. Since you are running in Eclipse, edit -Xmx value at the end of the eclipse.ini file. It is probably set to 512m, try using 1024m. If you are running ant from the command line, you can increase the heap size by setting the ANT_OPTS env var. Here's a Windows example:

set ANT_OPTS=-Xmx1024m

Regarding the fork issue, please post the javac task from the build file, and provide the values for any properties used within javac.
 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Peter Johnson wrote:You should try increasing the heap size. Since you are running in Eclipse, edit -Xmx value at the end of the eclipse.ini file.



You are correct, it was originally at 512m, but I had already set to 1024m (see second "code" formatted section above) in my attempts to solve the problem prior to posting.

Peter Johnson wrote:
Regarding the fork issue, please post the javac task from the build file, and provide the values for any properties used within javac.



The only property used is source.dir, which is set to:

Well, the original javac is in my original post above, just shortened some repetitive lines to save space.

So, when the javac element is set to:

with the rest of the code the same, I get the Out Of Memory issue, about 80% of the time. Seems like about 1 out of 5 attempts, making NO changes, succeeds.

When I do either of the following:

or

with the rest of the code the same, I get the aforementioned "invalid flag" complaint.

Am I missing anything?
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wait a minutes, I just now saw that you have forked set to true for the java task. You will have to set the max heap size for that task. Use the memoryMaximumSize property.

I realize that you are doing this within Eclipse, but it is probably better to try running Ant from the command line and making sure it runs correctly there first before attempting it within Eclipse . Something Eclipse's attempt to be "helpful" leads to nothing but aggravation and heartache.
 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like I might have to try doing it outside of Eclipse. Even when I include the memoryMaximumSize property, having the fork attribute still causes the "invalid flag" message mentioned in my first post in this thread.
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic