开发者

JUnit test runs out of memory -- how to increase heap size?

I am running a Junit test which throws an exception OutOfMemory. The test is started inside NetBeans 6.9.X. When profiling it I've realized that the Heap maxSize is 64M. I would like to increment this but I couldn't find how to do this.

I already tried right click at the project ->properties ->Run and under the VM options I've set -Xms300M开发者_运维知识库 but this didn't work.

Any hint?

Thanks in advance.


From http://wiki.gephi.org/index.php/NetBeans_Tips#How_to_increase_Heap_Size_for_JUnit_test

Edit your project.properties file and add the line:

test.run.args=-Xms128m -Xmx1400m


You can also increase the max size for all VMs by setting this environment variable for your OS:

 _JAVA_OPTIONS=-Xmx300m


Have you adjusted -Xmx as well as -Xms

-Xms300m will force java using no less 300m, and -Xmx300m will let jvm use no more than 300m


You can try this and see if it helps:

-XX:MaxPermSize=128m


While Java program usually don't leak memory in usual sense there could be memory unnecessarily occupied in collections like lists and maps. Use a profiler to see where the memory is being used, you will likely find opportunities for optimization.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜