问题描述
今天idea构建一个新的项目时报错:GC overhead limit exceeded,错误是发生在编译阶段,而不是运行阶段。
ava: GC overhead limit exceeded
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.sun.tools.javac.resources.compiler.getContents(compiler.java:5)
at java.util.ListResourceBundle.loadLookup(ListResourceBundle.java:195)
at java.util.ListResourceBundle.handleGetObject(ListResourceBundle.java:130)
at java.util.ResourceBundle.getObject(ResourceBundle.java:441)
at java.util.ResourceBundle.getObject(ResourceBundle.java:444)
at java.util.ResourceBundle.getString(ResourceBundle.java:407)
at com.sun.tools.javac.util.JavacMessages.getLocalizedString(JavacMessages.java:190)
at com.sun.tools.javac.util.JavacMessages.getLocalizedString(JavacMessages.java:141)
at com.sun.tools.javac.util.JavacMessages.getLocalizedString(JavacMessages.java:135)
at com.sun.tools.javac.util.Log.localize(Log.java:684)
at com.sun.tools.javac.util.Log.printLines(Log.java:497)
at com.sun.tools.javac.main.Main.resourceMessage(Main.java:610)
at com.sun.tools.javac.main.Main.compile(Main.java:543)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:237)
at org.jetbrains.jps.javac.ExternalJavacProcess.compile(ExternalJavacProcess.java:196)
at org.jetbrains.jps.javac.ExternalJavacProcess.access$400(ExternalJavacProcess.java:30)
at org.jetbrains.jps.javac.ExternalJavacProcess$CompilationRequestsHandler$1.run(ExternalJavacProcess.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
问题原因
1、idea的构建项目进程所使用的的虚拟机和idea自身使用的虚拟机不是同一个。
2、idea默认构建进程虚拟机给的内存太小
解决办法
修改idea构建进程内存大小,FIle->Settings->Build->Compiler