12

I have given loads of memory to eclipse in the ini file but its still not using anything more than 300mb which i can see in the task manager.

  [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.comp.Attr.selectSym(Attr.java:1938)
    [javac]     at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:1835)
    [javac]     at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1522)
    [javac]     at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
    [javac]     at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:377)
    [javac]     at com.sun.tools.javac.comp.Annotate.enterAttributeValue(Annotate.java:190)
    [javac]     at com.sun.tools.javac.comp.Annotate.enterAnnotation(Annotate.java:167)
    [javac]     at com.sun.tools.javac.comp.MemberEnter.enterAnnotations(MemberEnter.java:743)
    [javac]     at com.sun.tools.javac.comp.MemberEnter.access$300(MemberEnter.java:42)
    [javac]     at com.sun.tools.javac.comp.MemberEnter$5.enterAnnotation(MemberEnter.java:711)
    [javac]     at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:95)
    [javac]     at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:87)
    [javac]     at com.sun.tools.javac.comp.Enter.complete(Enter.java:485)
    [javac]     at com.sun.tools.javac.comp.Enter.main(Enter.java:442)
    [javac]     at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:819)
    [javac]     at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:353)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:279)
    [javac]     at com.sun.tools.javac.main.Main.compile(Main.java:270)
    [javac]     at com.sun.tools.javac.Main.compile(Main.java:69)
    [javac]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [javac]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:597)
    [javac]     at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
    [javac]     at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1065)
    [javac]     at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:882)
    [javac]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
    [javac]     at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
    [javac]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [javac]     at java.lang.reflect.Method.invoke(Method.java:597)
    [javac]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)

this is my ini file which i have.

--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize1024m
--vm
C:\Program Files\Java\jdk1.6.0_24\bin\javaw.exe -vmargs -Xms512m -Xmx1024m

I have no idea why it wont use the memory I am giving it. Do i need to do anything else to change the heap size?

Thanks

nturner
  • 146
  • 6
LinuxBill
  • 415
  • 1
  • 8
  • 19

5 Answers5

18

Not Eclipse is running out of memory, but ant. Ant is run as an external tool from eclipse, so it does not inherit the VM settings you are using for eclipse. You can set the options for it in the external tool run configuration. Go to Run -> External Tools -> External Tool Configurations... Then under "Ant Builds" you have to look up your ant build, and you can set the vm arguments in the JRE tab.

Thomas Lötzer
  • 24,832
  • 16
  • 69
  • 55
  • I have given ANT loads of memory from in the external tools. It should not be running out of memory. I have set it ANT_OPTS to 1024 and 512 – LinuxBill Apr 07 '11 at 09:58
  • 2
    ANT_OPTS is ignored when running ant from eclipse. See eclipse bug at https://bugs.eclipse.org/bugs/show_bug.cgi?id=26491 You need to use the vm arguments you already used in your eclipse.ini – Thomas Lötzer Apr 07 '11 at 11:30
4

your eclipse.ini settings will take effect only if u change following:

Run -> External Tools -> External Tool

Configurations. go to configuration that u use, under jre tab -select option

Run in same JRE in workspace



this worked 4 me

Nirmal- thInk beYond
  • 11,847
  • 8
  • 35
  • 46
  • Again just tried that and it didnt work! What is wrong with this its using the jdk1.6 freshly downloaded and installed. ANT_OPTS and JAVA_OPTS are set in the windows variables. – LinuxBill Apr 07 '11 at 10:38
  • under same tab try `use separate jre` and below that in vm arg put -`Xms512m -Xmx1024m` may b work – Nirmal- thInk beYond Apr 07 '11 at 10:46
0

You can properly set the -Xms512m -Xmx1024m options to the Ant bin/sh script that Eclipse will run once you launch a build.

  1. Go to your Eclipse folder
  2. Go to plugins > org.apache.ant_<version> > bin
  3. Modify the OS related Ant file

    • For Windows: Add this line to the ant.bat file export ANT_OPTS=-Xmx512m

    • For Unix/Mac OS X: You can directly edit the ant_exec_command command at the end of the ant file or setting the $ANT_ARGS variable

araknoid
  • 3,065
  • 5
  • 33
  • 35
0

I had the same problem a week ago, and the solution was set fork attribute to true, to run javac in a separate process with its own heap size settings. If fork is set to false, or not set (default is false), javac will run in the same process as Ant. The following is a snippet from my current build.xml:

<javac fork="true"
       srcdir="${basedir}/src"
       .....
</javac>

Setting fork to true will also limit any memory leaks in javac implementation to its own child process, without affecting the parent Ant process. I read about this hint here

Aitor
  • 3,309
  • 2
  • 27
  • 32
0

See this topic with best Eclipse JVM settings

Community
  • 1
  • 1
ilalex
  • 3,018
  • 2
  • 24
  • 37