本文介绍了java:OutOfMemoryError:在Idea中运行JUnits时内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的IntelliJ Idea运行JUnits
当我尝试运行Test.java文件时,它给出了一个错误,说明

I am trying to run JUnits from my IntelliJ IdeaWhen I try to run the Test.java file it gives me an error saying that

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

I have tried increasing the memory allocated to Idea to as large as 6GB but it still gives me the same error, what am I missing :/

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

Increasing the following in idea64.vmoptions didn't help. current vmoption settings in /opt/idea/bin are:

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

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

PS:- the project has ~83k files and overall size of project is 1.1 GB

遇到以下错误: -

Below Error is encountered:-

推荐答案

Idea在单独的java进程中运行单元测试。

Idea runs unit tests in a separate java process.

你需要使用

Run -> Edit Configurations...

并添加 -XmxNNNm 到VM选项。

例如:

-ea -Xmx1024m

-ea表示启用断言。

如果您的单元测试无法在1GB内存中运行,那么可能是内存泄漏。

If your unit test(s) can't run in a 1GB of memory then it's possible that you have a memory leak.

这篇关于java:OutOfMemoryError:在Idea中运行JUnits时内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 05:12
查看更多