gpt4 book ai didi

java: OutOfMemoryError: 在 Idea 中运行 JUnits 时内存不足

转载 作者:搜寻专家 更新时间:2023-10-30 20:55:16 27 4
gpt4 key购买 nike

我正在尝试从我的 IntelliJ Idea 运行 JUnit当我尝试运行 Test.java 文件时,它给我一个错误提示

java: OutOfMemoryError: insufficient memory

我已经尝试将分配给 Idea 的内存增加到 6GB,但它仍然给我同样的错误,我错过了什么:/

idea64.vmoptions 中增加以下内容没有帮助。/opt/idea/bin 中的当前 vmoption 设置为:

-Xms124m
-Xmx2g
-XX:MaxPermSize=2g
-XX:ReservedCodeCacheSize=196m
-XX:+UseCodeCacheFlushing
-ea
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true

PS:- 该项目有约 83k 个文件,项目总大小为 1.1 GB

遇到以下错误:-

Information:Using javac 1.6.0_35 to compile java sources Information:java: The system is out of resources. Information:java: Consult the following stack trace for details. Information:java: at com.sun.tools.javac.util.Position$LineMapImpl.build(Position.java:139) Information:java: at com.sun.tools.javac.util.Position.makeLineMap(Position.java:63) Information:java: at com.sun.tools.javac.parser.Scanner.getLineMap(Scanner.java:1105) Information:java: at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:512) Information:java: at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:550) Information:java: at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:804) Information:java: at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727) Information:java: at com.sun.tools.javac.main.Main.compile(Main.java:353) Information:java: at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115) Information:java: at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:166) Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:364) Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:276) Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:190) Information:java: at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:162) Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:992) Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:739) Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:769) Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:702) Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:523) Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:314) Information:java: at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:179) Information:java: at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:129) Information:java: at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:216) Information:java: at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:111) Information:java: at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:132) Information:java: at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41) Information:java: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) Information:java: at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) Information:java: at java.util.concurrent.FutureTask.run(FutureTask.java:138) Information:java: at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) Information:java: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) Information:java: at java.lang.Thread.run(Thread.java:662) Information:java: Errors occurred while compiling module 'app' Information:Compilation completed with 1 error and 0 warnings in 3 min 19 sec Information:1 error Information:0 warnings Error:java: OutOfMemoryError: insufficient memory

IDEA COMPILER SETTINGS

最佳答案

根据您的日志,问题出在编译器堆空间中。

转到

Settings -> Compiler -> Build process heap size (MB)

并增加该值。

关于java: OutOfMemoryError: 在 Idea 中运行 JUnits 时内存不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24323628/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com