-
Notifications
You must be signed in to change notification settings - Fork 435
Description
Describe the bug
We noticed an important increase of RAM for unit tests when bumping following Spring libraries in my company (SBS software):
- Spring Cloud 2023.0.1 to 2024.0.1 (SCC 4.2.1)
- Spring Boot 3.3.8 to 3.4.4.
On some projects, unit tests require an additional 2Go to run.
According to our investigations, the increase is caused by a change in spring-core 6.2.0: spring-projects/spring-framework#33705
This PR adds a jarEntriesCache in PathMatchingResourcePatternResolver used internally by SCC ResourceResolvingStubDownloader.
On our test project, this jar entries cache is about 24Mo per instance and it is instantiated +/- 80 times by our unit tests (due to multiple stubs libraries and test application contexts).
I've noticed that the jar entries cache is not used after the stubs have been unpacked in a temp dir by ResourceResolvingStubDownloader.
I would therefore propose to call the method PathMatchingResourcePatternResolver.clearCache()
(introduced in spring-core 6.2) to clear the jar entries cache after resolving the stubs resources in ResourceResolvingStubDownloader.
Sample
The test project is internal to our company and can't be shared on GitHub.
I would however be happy to provide a PR and test it on our test project to validate that it fixes the memory issue.