2011-12-20 41 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