gpt4 book ai didi

java - Intellij 内存不足错误 : PermGenSpace with Scala

转载 作者:行者123 更新时间:2023-12-02 11:03:33 25 4
gpt4 key购买 nike

是的,在您将其标记为重复之前,我已经阅读过

How to prevent java.lang.OutOfMemoryError: PermGen space?

How to prevent java.lang.OutOfMemoryError: PermGen space at Scala compilation?

但它没有为我提供任何解决方案。

问题来了

我在使用 junit 编写的应用程序中确实有一个简单的测试,例如:

public class FooTest extends BaseTest {

@Test
public void testSomeMethod() {
...
//Some Asserts
...
}
}

我尝试通过简单地单击“运行”来使用 Intellij 运行此测试:

然后创建以下配置:

Intellij Test Configuration

运行测试打印然后执行以下操作:

[IJ][pos] $ all {file:/C:/somepath/test/}pos/foopackage {file:/C:/somepath/test/}pos/test:foopackage
[info] Compiling 1 Scala source and 6 Java sources to C:\somepath\test\target\scala-2.11\classes...
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at sbt.ConcurrentRestrictions$$anon$4.take(ConcurrentRestrictions.scala:188)
at sbt.Execute.next$1(Execute.scala:83)
at sbt.Execute.processAll(Execute.scala:86)
at sbt.Execute.runKeep(Execute.scala:66)
at sbt.EvaluateTask$.liftedTree1$1(EvaluateTask.scala:359)
at sbt.EvaluateTask$.run$1(EvaluateTask.scala:358)
at sbt.EvaluateTask$.runTask(EvaluateTask.scala:378)
at sbt.Aggregation$$anonfun$3.apply(Aggregation.scala:64)
at sbt.Aggregation$$anonfun$3.apply(Aggregation.scala:62)
at sbt.EvaluateTask$.withStreams(EvaluateTask.scala:314)
at sbt.Aggregation$.timedRun(Aggregation.scala:62)
at sbt.Aggregation$.runTasks(Aggregation.scala:71)
at sbt.Aggregation$$anonfun$applyTasks$1.apply(Aggregation.scala:32)
at sbt.Aggregation$$anonfun$applyTasks$1.apply(Aggregation.scala:31)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Aggregation$$anonfun$evaluatingParser$4$$anonfun$apply$5.apply(Aggregation.scala:153)
at sbt.Aggregation$$anonfun$evaluatingParser$4$$anonfun$apply$5.apply(Aggregation.scala:152)
at sbt.Act$$anonfun$sbt$Act$$actParser0$1$$anonfun$sbt$Act$$anonfun$$evaluate$1$1$$anonfun$apply$10.apply(Act.scala:244)
at sbt.Act$$anonfun$sbt$Act$$actParser0$1$$anonfun$sbt$Act$$anonfun$$evaluate$1$1$$anonfun$apply$10.apply(Act.scala:241)
at sbt.Command$.process(Command.scala:93)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.State$$anon$1.process(State.scala:184)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:98)
at sbt.MainLoop$.run(MainLoop.scala:91)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
at sbt.MainLoop$.runLogged(MainLoop.scala:24)
at sbt.StandardMain$.runManaged(Main.scala:53)
at sbt.xMain.run(Main.scala:28)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.OutOfMemoryError: PermGen space
[error] java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
[error] Use 'last' for the full log.
[IJ][pos] $
[IJ][pos] $

这是我迄今为止尝试过的:

正如我提到的已经发布的问题,我尝试通过在我的系统上配置已安装的 sbt 来消除此错误:

我安装的sbt版本目前是0.13.15

所以我配置了:

C:\installpath\Scala\sbt_0_13_15\conf\sbtconfig.txt

如下所示:

-Xmx2G
-Xms2G
-XX:MaxPermSize=256m
-XX:ReservedCodeCacheSize=256m
-Dsbt.log.format=false
-XX:+CMSClassUnloadingEnabled

但我仍然遇到同样的错误。因此,我检查了 Intellij 从哪里获取 sbt,以及从控制台使用 sbt test 构建是否也会失败。

sbt test

似乎运行成功:

[info] Done updating.
[info] Compiling 450 Scala sources and 1132 Java sources to C:\somepath\test\target\scala-2.11\classes
[info] Weaving 1 input to C:\somepath\test\target\scala-2.11\aspectj\classes...
[info] Compiling 103 Java sources to C:\somepath\test\target\scala-2.11\test-classes...
[info] Instrumenting 6228 classes to C:\somepath\test\target\scala-2.11\jacoco\instrumented-classes
...
[info] 2 tests, 0 failures, 0 errors
... And goes on and on

所以我检查了它在 Intellij 中的配置方式:

sbt Configuration

作为虚拟机参数,我还输入了:

-Xmx2G -Xms2G -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=256m -Dsbt.log.format=false -XX:+CMSClassUnloadingEnabled

但我仍然遇到同样的错误。

然后我尝试将 .sbtopts 文件添加到 root 文件夹中。

文件内容为:

-J-Xmx2G
-J-Xms2G
-J-XX:MaxPermSize=1G
-J-XX+CMSClassUnloadingEnabled

删除后

-J-XX+CMSClassUnloadingEnabled

.sbtopts - 项目文件夹中的文件可以构建项目。

似乎出现了这个异常:

C:\Java7\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=localhost:53488,suspend=n,server=y -Xdebug -server -Xmx2G -Xms2G -XX:MaxPermSize=1G -XX+CMSClassUnloadingEnabled -Xmx2048M -Dfile.encoding=UTF-8 -Didea.runid=2017.2 -Didea.managed=true -jar C:\installpath\Scala\sbt_0_13_15\bin\sbt-launch.jar idea-shell
Unrecognized option: -XX+CMSClassUnloadingEnabled
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

最佳答案

删除后

-J-XX+CMSClassUnloadingEnabled

.sbtopts - 项目文件夹中的文件可以构建项目。

似乎出现了这个异常:

C:\Java7\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=localhost:53488,suspend=n,server=y -Xdebug -server -Xmx2G -Xms2G -XX:MaxPermSize=1G -XX+CMSClassUnloadingEnabled -Xmx2048M -Dfile.encoding=UTF-8 -Didea.runid=2017.2 -Didea.managed=true -jar C:\installpath\Scala\sbt_0_13_15\bin\sbt-launch.jar idea-shell
Unrecognized option: -XX+CMSClassUnloadingEnabled
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

关于java - Intellij 内存不足错误 : PermGenSpace with Scala,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51150369/

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