Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javac: java.lang.OutOfMemoryError when running ant from Eclipse

Tags:

java

eclipse

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

like image 677
LinuxBill Avatar asked Apr 07 '11 09:04

LinuxBill


People also ask

How do I fix Java Lang OutOfMemoryError?

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 Java Lang OutOfMemoryError Java heap space?

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. lang. OutOfMemoryError .


1 Answers

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.

like image 89
Thomas Lötzer Avatar answered Sep 23 '22 18:09

Thomas Lötzer