为什么堆空间仅在运行JUnit测试时耗尽? [英] Why does heap space run out only when running JUnit tests?

查看:157
本文介绍了为什么堆空间仅在运行JUnit测试时耗尽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行JUnit测试时,我总是遇到这个错误:

When running JUnit tests, I always seem to run into this error:


eclipse outOfMemoryError:堆空间

eclipse outOfMemoryError: heap space

我已经使用JConsole和堆内存峰值监视了大约150MB的Eclipse。我将堆内存设置为1GB。

I have monitored Eclipse with JConsole and heap memory peaks at about 150MB. I have set heap memory to 1GB.

启动Eclipse时,我使用以下参数:

I am using the following arguments when starting Eclipse:


-vm "C:\Program Files\Java\jre1.5.0_08\bin\javaw.exe" -vmargs -Xmx1024M
-XX:MaxPermSize=128M -Dcom.sun.management.jmxremote.port=8999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

有谁知道可能导致这个问题?只有运行JUnit测试才会发生。

Does anyone know what may be causing this issue? It happens only when running JUnit tests.

推荐答案

Junit测试以不同的vm作为Eclipse IDE运行。所以这是那个内存不足而不是Eclipse的vm。

您可以在测试的运行配置中更改测试vm的设置。

您转到运行配置,然后在参数下,可以设置vm参数。

Junit tests are run in a different vm as the Eclipse IDE. So it is that vm that is out of memory and not the Eclipse one.
You can change the settings of the test vm in the run configurations of the test.
You go to the run configurations and then under arguments, you can set the vm arguments.

这篇关于为什么堆空间仅在运行JUnit测试时耗尽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆