Description
Eric Sirianni opened SPR-7687 and commented
We are using the Spring TestContext framework (SpringJUnit4ClassRunner) for JUnit test execution. We are hitting OutOfMemoryErrors when running a large number of tests in batch. The problem is that the ApplicationContext objects are building up in the ContextCache (org.springframework.test.context.ContextCache), consuming a large amount of memory.
We have worked around the problem by annotating @DirtiesContext
on each JUnit test class.
However, it seems that this issue could be avoided if ContextCache wrapped its cached ApplicationContexts in WeakReferences. This seems to be a best practice when caching potentially large objects such as these.
Affects: 3.0.3
Issue Links:
- Allow for concurrent test execution in the TestContext framework [SPR-5863] #10532 Allow for concurrent test execution in the TestContext framework
- Introduce system property to disable context caching in the TestContext framework [SPR-11576] #16200 Introduce system property to disable context caching in the TestContext framework
- Limit size of context cache in the TestContext framework [SPR-8055] #12710 Limit size of context cache in the TestContext framework ("is superseded by")
Referenced from: commits 0cb22fc, d66d160
2 votes, 4 watchers