Running a large number of tests causes Eclipse to freeze, continue to freeze, etc.

I noticed that running large Junit 3.x test suites causes Eclipse to fight and block. Even when I allocate a lot of heaps and perm gen (1200 m and 400 m), it buzzes along, and then just freezes, and then continues, taking quite a lot of time. If I run tests in small batches, then everything is pretty fast, and freezing to a large extent will never happen.

I checked the memory usage during test execution and they are not somewhere near the maximum for the given maximum heap or perm, so they should not be a problem ...

Does anyone have any tips on getting around this.

+4
source share
3 answers

It may already be something you tried, but ... if you use your unit tests like "JUnit plug-in tests" ... then your settings for Xmx and MaxPermSize in eclispe.ini are useless.

The eclipse.ini options let you change the settings for the current Eclipse. Any Eclipse instance created from this Eclipse will still have default settings (something like Xms40m and Xmx512m). You must also change them.

Open the launch configuration that you use for your tests (Run> Run Configurations ..., select the one you use to run unit tests) and go to the "Arguments" tab. There, in the โ€œVM Argumentsโ€ text area, enter the new memory parameters, as in the eclipse.ini file (I use -Xms256m -Xmx1536m -XX:MaxPermSize=256m for the most expensive test suites ... but you may need more).

A major issue may be trying to fix potential memory leaks in your unit tests. Are you sure there is no more unloading / freeing memory / ... in tearDown() ? Running tests on profiling can help (we use the Mykit java profiler for this purpose, where I work ... but it is not free. JConsole can help you, see also http://java.sun.com/developer/technicalArticles/ J2SE / jconsole.html ).

+3
source

It is not allowed to comment and therefore add it here .. you have checked the memory, therefore this option is closed

Few other things to try:

I'm not sure if you tried to play with fork options on junit.

Does it restore target classes again? Can you see the destination folder?

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

0
source

Your program may have some kind of memory leak, which appears only if you run all the tests. You did not mention if you have the same problems, if you run your tests from the outside.

I would recommend running some kind of memory analyzer during freezing. Something like MAT http://www.eclipse.org/mat/ has helped me in the past. You can also try running multiple jstack sessions to get an idea of โ€‹โ€‹what happens over time.

0
source

Source: https://habr.com/ru/post/1337951/


All Articles