2011-12-20 142 views
54

当我制作一个Intellij项目时,我不断收到以下内存不足错误。我怎样才能给Intellij编译器更多的堆空间?

我已经在idea.vmoptions增加了我的堆大小:

-Xms128m 
-Xmx2048m 
-XX:MaxPermSize=1024m 
-XX:ReservedCodeCacheSize=64m 
-ea 

但我仍然得到这个错误:

Information:The system is out of resources. 
Information:Consult the following stack trace for details. 
Information:java.lang.OutOfMemoryError: Java heap space 
Information: at com.sun.tools.javac.util.Position$LineMapImpl.build(Position.java:139) 
Information: at com.sun.tools.javac.util.Position.makeLineMap(Position.java:63) 
Information: at com.sun.tools.javac.parser.Scanner.getLineMap(Scanner.java:1105) 
Information: at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:512) 
Information: at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:550) 
Information: at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:804) 
Information: at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727) 
Information: at com.sun.tools.javac.main.Main.compile(Main.java:353) 
Information: at com.sun.tools.javac.main.Main.compile(Main.java:279) 
Information: at com.sun.tools.javac.main.Main.compile(Main.java:270) 
Information: at com.sun.tools.javac.Main.compile(Main.java:69) 
Information: at com.sun.tools.javac.Main.main(Main.java:54) 
Information: at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
Information: at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
Information: at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
Information: at java.lang.reflect.Method.invoke(Method.java:597) 
Information: at com.intellij.rt.compiler.JavacRunner.main(JavacRunner.java:71) 
Information:Compilation completed with 1 error and 0 warnings 
Information:1 error 
Information:0 warnings 
Error:Compiler internal error. Process terminated with exit code 3 

我缺少什么?

回答

75

当前版本:

SettingsPreferences在Mac)| Build, Execution, Deployment | Compiler | 构建过程堆大小

旧版本:

SettingsPreferences在Mac)| Compiler | Java Compiler | 最大堆大小

编译器在默认情况下在单独的JVM中运行,因此您在idea.vmoptions中设置的IDEA堆设置对编译器没有影响。

+6

并在重新启动之后是需要:) – cgl 2013-04-16 16:23:49

+3

其实这是不 – jarandaf 2013-09-15 16:36:36

+5

我知道这是稍微偏离主题,但可能会节省一些人的头发,如果他们碰到过这个。我遇到了同样的问题,但是当我在IntelliJ中执行'mvn install'时,我的情况就是这样。解决方案是修改'Settings | Maven |亚军| **虚拟机选项**'我必须尝试其他所有设置,直到我找到一个正确的。希望它能帮助别人。 – FuriousGeorge 2013-09-26 19:54:29

3

在GWT的IntelliJ 12

FWIW,我是在'构建让我的GWT应用程序类似的错误|重建项目'。

这是由于Intellij做了一个完整的GWT编译,我不喜欢它,因为它也是一个非常冗长的过程。

我通过关闭'下的模块复选框来禁用GWT编译项目结构|方面| GWT'。

或者,在该位置也有'编译器最大堆大小'设置。

0

在我的情况下,错误是由于分配给maven的“测试”生命周期的内存不足导致的。它是固定的,加入到<argLine>-Xms3512m -Xmx3512m</argLine>

<pluginManagement> 
    <plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>2.16</version> 
     <configuration> 
      <argLine>-Xms3512m -Xmx3512m</argLine> 

感谢@crazycoder指出了这一点(也即它不涉及的IntelliJ;在这种情况下)。

If your tests are forked, they run in a new JVM that doesn't inherit Maven JVM options. Custom memory options must be provided via the test runner in pom.xml, refer to Maven documentation for details, it has very little to do with the IDE.

-3

有一个

idea64.exe

起动器

IntelliJ IDEA 13.1.5\bin

这样你就可以解决更多的空间。

+0

这个答案在一定程度上是正确的,虽然不在上述问题的背景下。 idea64.exe确实为您提供更多的permgen内存,如果您使用的是64位操作系统,请使用idea64.exe。发现它有用的coz 32位idea.exe在构建期间耗尽mem时崩溃。 – 2017-04-18 16:24:33

56

由于IntelliJ 2016,位置是文件|设置|构建,执行,部署|编译器|构建进程堆大小

enter image description here

1

我曾与Ant构建(用手从IDEA GUI启动)类似的问题。在我的情况下,右键单击Ant任务,选择属性并将较高值设置为“最大堆空间(Mb):”和“最大堆栈空间(Mb):”输入字段是正确的解决方案。

enter image description here