Ant with JUnit task - OutOfMemoryError

2019-07-19 19:25发布

问题:

I have an interesting problem. I am using Ant which executes JUnit tests (test suite composed with 50 tests) via build.xml element. The problem is that I receive OutOfMemoryError.

I have enlarged heap space using ANT_OPTS arguments but it did not help. When I execute the same test suite in Eclipse - everything is fine - memory is released thanks to GC.

I think that this problem is related to Ant and its JUnit task.

Maybe logging of the tests are the reason(but on the other hand I have printsummary="false", [maybe outputtoformatters should be set to false as well???]).

My second guess is that TEST***.xml file (generated at the end of the test) is held in memory and flushed at the end of the test. Is there any way to reduce logs which are in that file?

Guys, please give me some clues.

回答1:

You need to set the maxmemory attribute in the junit task. See the Ant documentation.



回答2:

to sum up I want to say that the root of the problems was logging. Logs were sent to the stream and not flushed. After switching the logs off - everything was fine.



回答3:

By default the fork mode is off. Please try with fork mode on and forkmode set to pertest.