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

前端 未结 5 867
天涯浪人
天涯浪人 2021-02-13 19:16

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 syst         


        
相关标签:
5条回答
  • 2021-02-13 19:43

    See this topic with best Eclipse JVM settings

    0 讨论(0)
  • 2021-02-13 19:47

    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

    0 讨论(0)
  • 2021-02-13 19:50

    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

    0 讨论(0)
  • 2021-02-13 19:55

    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.

    0 讨论(0)
  • 2021-02-13 19:56

    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

    0 讨论(0)
提交回复
热议问题