Running lots of tests causes Eclipse to freeze, continue freeze etc

2.6k views Asked by At

I have noticed that executing large mostly Junit 3.x test suites, causes Eclipse to shititself and lockup. Even when i allocate a lot of heap and perm gen (1200m and 400m) it hums along and then just freezes and then continues, taking quite some time. If i run the tests in small batches then things are fairly quick and the freezes pretty much never happen.

I have checked the memory usage while the tests run and they are no where near the maximum for either the given max heap or perm, so those should not be a problem...

Does anyone have tips on how to get around this.

3

There are 3 answers

1
luckylak On

Not allowed to comment and hence Adding it here.. you have checked the memory, hence that option is closed

Few other things to try:

I am not sure, if you tried playing with the fork options on junit.

Is it rebuilding the target classes again and again? Can you watch the target folder?

Did you try recreating the workspace? Just suggesting this because you seem to have covered the main issues - memory, logging etc..

2
Kellindil On

This might already be something you tried but ... if you are running your unit tests as "JUnit plug-in tests" ... then your settings for Xmx and MaxPermSize in eclispe.ini are useless.

eclipse.ini settings allow you to change the settings for your current Eclipse. Any Eclipse instance spawned from this Eclipse will still have the defaults settings (something like Xms40m and Xmx512m). You also have to change these.

Open the launch configuration you use for your tests ("Run > Run Configurations...", select the one you use to launch your unit tests) and go to the "Arguments" tab. There, in the "VM Arguments" text area, input your new memory settings as you did in the eclipse.ini file (I use -Xms256m -Xmx1536m -XX:MaxPermSize=256m for my most expensive test suites ... but you might need more).

The main issue though might be to try and fix the potential memory leaks of your unit tests. Are you sure you don't have more unloading/memory freeing/... in the tearDown()? Running your tests under profiling might help (we use Yourkit java profiler to this end where I work... but it isn't free. JConsole might help you there, see also http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html).

0
Andrew Eisenberg On

There may be some kind of memory leak in your program that only appears if you run all the tests. You haven't mentioned if you get the same problems if you run your tests externally.

I would recommend running some kind of memory analyzer around the time of the freeze-up. Something like MAT http://www.eclipse.org/mat/ has helped me in the past. You could also try running multiple sessions of jstack to get an idea of what is happening over time.