简体   繁体   English

即使在增加堆大小后,IntelliJ Idea 也会给出 java.lang.OutOfMemoryError: Java 堆空间错误

[英]IntelliJ Idea giving java.lang.OutOfMemoryError: Java heap space error even after increasing heap size

I have repeatedly got the java.lang.OutOfMemoryError: Java heap space error when compiling my android project on IntelliJ Idea.在 IntelliJ Idea 上编译我的 android 项目时,我反复收到java.lang.OutOfMemoryError: Java heap space错误。

I increased my java heap space by following the link here however that didn't solve the problem.我通过点击此处的链接增加了 java 堆空间,但这并没有解决问题。 The funny thing is, at times my app will compile, and at other times the app will not compile due to the java heap space error.有趣的是,有时我的应用程序会编译,而有时由于 java 堆空间错误,应用程序将无法编译。 Even when I have made no changes to the app, it will compile at times and fail at times.即使我没有对应用程序进行任何更改,它有时也会编译并有时会失败。

Any idea as to how I can solve this problem?关于如何解决这个问题的任何想法?

I am compiling an android project, could it be due to the large amount or resources (drawable hdpi, xhdpi, xxhdpi, large-hdpi, large-xhdpi, large-xxhdpi) that I have?我正在编译一个 android 项目,可能是由于我拥有的大量或资源(可绘制 hdpi、xhdpi、xxhdpi、large-hdpi、large-xhdpi、large-xxhdpi)吗? But then again, like I said it compiles at times and at times it doesn't.但是话又说回来,就像我说的那样,它有时会编译,有时却不会。 I'm down to making about 10 attempts to compile each time and luckily it will be successful once.我每次尝试编译大约 10 次,幸运的是它会成功一次。

Here is the error:这是错误:

Internal error: (java.lang.OutOfMemoryError) Java heap space java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2271) at com.intellij.util.io.UnsyncByteArrayOutputStream.write(UnsyncByteArrayOutputStream.java:52) at com.intellij.util.io.DataOutputStream.write(DataOutputStream.java:34) at java.io.FilterOutputStream.write(FilterOutputStream.java:97) at com.intellij.util.io.IOUtil.writeString(IOUtil.java:63) at org.jet Internal error: (java.lang.OutOfMemoryError) Java heap space java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Arrays.java:2271) at com.intellij.util.io.UnsyncByteArrayOutputStream.write( UnsyncByteArrayOutputStream.java:52) at com.intellij.util.io.DataOutputStream.write(DataOutputStream.java:34) at java.io.FilterOutputStream.write(FilterOutputStream.java:97) at com.intellij.util.io.IOUtil .writeString(IOUtil.java:63) 在 org.jet brains.jps.incremental.storage.OneToManyPathsMapping$PathCollectionExternalizer.save(OneToManyPathsMapping.java:87) at org.jetbrains.jps.incremental.storage.OneToManyPathsMapping$PathCollectionExternalizer.save(OneToManyPathsMapping.java:84) at org.jetbrains.jps.incremental.storage.AbstractStateStorage$1.append(AbstractStateStorage.java:103) at com.intellij.util.io.PersistentHashMap.doAppendData(PersistentHashMap.java:371) at com.intellij.util.io.PersistentHashMap.appendData(PersistentHashMap.java:358) at org.jetbrains.jps.incremental.storage.AbstractStateStorage.appendData(AbstractStateStorage.java:101) at org.jetbrains.jps.incremental.storage.OneToManyPathsMapping.appendData(OneToMan brains.jps.incremental.storage.OneToManyPathsMapping$PathCollectionExternalizer.save(OneToManyPathsMapping.java:87) at org.jetbrains.jps.incremental.storage.OneToManyPathsMapping$PathCollectionExternalizer.save(OneToManyPathsMapping.java:84) at org.jetbrains.jps. incremental.storage.AbstractStateStorage$1.append(AbstractStateStorage.java:103) at com.intellij.util.io.PersistentHashMap.doAppendData(PersistentHashMap.java:371) at com.intellij.util.io.PersistentHashMap.appendData(PersistentHashMap.java :358) 在 org.jetbrains.jps.incremental.storage.AbstractStateStorage.appendData(AbstractStateStorage.java:101) 在 org.jetbrains.jps.incremental.storage.OneToManyPathsMapping.appendData(OneToMan yPathsMapping.java:50) at org.jetbrains.jps.incremental.storage.SourceToOutputMappingImpl.appendOutput(SourceToOutputMappingImpl.java:50) at org.jetbrains.jps.builders.impl.BuildOutputConsumerImpl.registerOutputFile(BuildOutputConsumerImpl.java:65) at org.jetbrains.jps.android.AndroidResourceCachingBuilder.runPngCaching(AndroidResourceCachingBuilder.java:126) at org.jetbrains.jps.android.AndroidResourceCachingBuilder.build(AndroidResourceCachingBuilder.java:48) at org.jetbrains.jps.android.AndroidResourceCachingBuilder.build(AndroidResourceCachingBuilder.java:32) at org.jetbrains.jps.incremental.BuildOperations.buildTarget(BuildOperations.java:100) at org.jetbrains.jps.incremental.IncProjectBuilder.r yPathsMapping.java:50) at org.jetbrains.jps.incremental.storage.SourceToOutputMappingImpl.appendOutput(SourceToOutputMappingImpl.java:50) at org.jetbrains.jps.builders.impl.BuildOutputConsumerImpl.registerOutputFile(BuildOutputConsumerImpl.java:65) at org .jetbrains.jps.android.AndroidResourceCachingBuilder.runPngCaching(AndroidResourceCachingBuilder.java:126) at org.jetbrains.jps.android.AndroidResourceCachingBuilder.build(AndroidResourceCachingBuilder.java:48) at org.jetbrains.jps.android.AndroidResourceCachingBuilder.build(AndroidResourceCachingBuilder .java:32) at org.jetbrains.jps.incremental.BuildOperations.buildTarget(BuildOperations.java:100) at org.jetbrains.jps.incremental.IncProject unBuildersForChunk(IncProjectBuilder.java:744) at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:770) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:702) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:523) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:314) at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:179) at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:129) at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:220) at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:112) at org. unBuildersForChunk(IncProjectBuilder.java:744) at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:770) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:702) at org.jetbrains .jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:523) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:314) at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java :179) at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:220) at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:129) BuildSession.run(BuildSession.java:112) 在组织。 jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:132) at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:132) at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41) at java.util.concurrent.Executors$ RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166)

Thanks in advance!提前致谢!

转到设置(Mac上的首选项) - >编译器 - > Java编译器 - >最大堆大小(MB),然后增加大小,然后重启IntelliJ

I just had this problem today, and after doubling/quadrupling the heap sizes under File/Settings/Compiler/Java Compiler and .../Compiler/Android Compiler and it still wouldn't compile. 我今天刚遇到这个问题,并且在文件/设置/编译器/ Java编译器和... /编译器/ Android编译器之后将堆大小加倍/翻两倍,它仍然无法编译。

the value that finally fixed my problem was increasing the value called Compiler Process Heap Size (I doubled it but that probably isn't necessary), which can be found under File/Settings/Compiler 最终修复我的问题的值是增加名为Compiler Process Heap Size的值(我加倍但可能没有必要),可以在File / Settings / Compiler下找到

this solved the problem for me using Intellij version 12.1.5 (the latest right now) 这解决了我使用Intellij 12.1.5版本的问题(现在最新版本)

also I realize that this thread is a bit old... 我也意识到这个线程有点老......

Intellij provides you with means to edit Application VM Options. Intellij为您提供了编辑应用程序VM选项的方法。 Edit Configurations, I think, is what you are after. 我认为,编辑配置就是你所追求的。 This setting is located in the top-right corner, or alternatively you can use shift-control-A "Edit configurations" you should see a dialog and one of the fields is VM Options. 此设置位于右上角,或者您可以使用shift-control-A“编辑配置”,您应该看到一个对话框,其中一个字段是VM选项。 Here you can set your application-specific settings, ie -Xmx2048m. 在这里,您可以设置特定于应用程序的设置,即-Xmx2048m。

In my case the error was appearing following a "Reload Project" from the "Maven" section.在我的情况下,错误出现在“Maven”部分的“重新加载项目”之后。 It was throwing the OutOfMemoryError in the "Sync" tab of the "Build" window.它在“构建”窗口的“同步”选项卡中抛出了OutOfMemoryError

In this case, the proper settings to increase is the VM options for importer that you can find in Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing.在这种情况下,适当增加的设置是VM options for importer器的VM options for importer ,您可以在设置 -> 构建、执行、部署 -> 构建工具 -> Maven -> 导入中找到。 In my case, it was set to 512m which was too slow for my project with about 50 modules or so.在我的例子中,它被设置为 512m,这对于我大约有 50 个模块的项目来说太慢了。

I increased the heap size and restarted the IntelliJ several times but it did not work out for me ...我增加了堆大小并重新启动了 IntelliJ 几次,但对我来说没有成功......

I simply went to build menu and clicked on rebuild project and everything was as good as before我只是去build菜单并单击rebuild project ,一切都和以前一样好

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使在将堆大小增加到最大之后,Jmeter仍可以为java.lang.OutOfMemoryError提供超过2000个线程 - Jmeter gives java.lang.OutOfMemoryError beyond 2000 threads, even after increasing the heap size to maximum 如何解决java.lang.OutOfMemoryError:Java堆空间而不增加堆内存大小 - How to resolve java.lang.OutOfMemoryError: Java heap space without increasing the heap memory size 在 Eclipse 中增加堆空间:(java.lang.OutOfMemoryError) - Increasing heap space in Eclipse: (java.lang.OutOfMemoryError) java.lang.OutOfMemoryError:IntelliJ 中的 Java 堆空间 - java.lang.OutOfMemoryError: Java heap space in IntelliJ 我如何解决java.lang.OutOfMemoryError:在增加堆大小的情况下,Java堆空间将意味着延迟OutOfMemoryError - How can I resolve java.lang.OutOfMemoryError: Java heap space in the case when increasing the heap size will mean delayed OutOfMemoryError java.lang.OutOfMemoryError:Java堆空间错误,同时在IntelliJ IDEA中通过Stax解析器解析5mb数据 - java.lang.OutOfMemoryError: Java heap space error,while parsing 5mb data through Stax parser in intellij idea java.lang.OutOfMemoryError:Java堆空间分配数组大小 - java.lang.OutOfMemoryError: Java heap space in allocating array size java.lang.OutOfMemoryError:Java堆空间 - java.lang.OutOfMemoryError: Java heap space java.lang.OutOfMemoryError:Java堆空间? - java.lang.OutOfMemoryError: Java heap space? java.lang.OutOfMemoryError:Java堆空间 - java.lang.OutOfMemoryError: Java heap space
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM