We run into memory problems on our buildstreet for automated tests.
We are using an abstract base class (removed non spring functionality)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
@DirtiesContext(classMode = ClassMode.BEFORE_EACH_TEST_METHOD) /
public abstract class AbstractEndToEndTest {
@DynamicPropertySource
static void registerDynamicProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", () -> POSTGRESS_SQL_CONTAINER.getJdbcUrl());
registry.add("spring.datasource.username", () -> POSTGRESS_SQL_CONTAINER.getUsername());
registry.add("spring.datasource.password", () -> POSTGRESS_SQL_CONTAINER.getPassword());
}
}
After some investigation we found that the org.springframework.boot.devtools.restart.Restarter is adding context to its rootContexts, however they never seems to be cleaned


|
private final List<ConfigurableApplicationContext> rootContexts = new CopyOnWriteArrayList<>(); |
Setting spring.test.context.cache.maxSize didn't help.
The current workaround is that we call the Restarter.clearInstance() after each test. However this is more a workaround. I would expect that the @SpringBootTest would clean this after the test has been run.
We run into memory problems on our buildstreet for automated tests.
We are using an abstract base class (removed non spring functionality)
After some investigation we found that the org.springframework.boot.devtools.restart.Restarter is adding context to its rootContexts, however they never seems to be cleaned


spring-boot/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java
Line 122 in c4368bc
Setting spring.test.context.cache.maxSize didn't help.
The current workaround is that we call the
Restarter.clearInstance()after each test. However this is more a workaround. I would expect that the@SpringBootTestwould clean this after the test has been run.