Skip to content
This repository was archived by the owner on Jul 7, 2026. It is now read-only.
This repository was archived by the owner on Jul 7, 2026. It is now read-only.

Important RAM increase since 4.2.x when stubs libraries are used in unit tests #2164

Description

@fstaudt

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.

Activity

  1. changed the title [-]Important RAM usage increase when ResourceResolvingStubDownloader is used in unit tests[/-] [+]Important RAM increase when ResourceResolvingStubDownloader is used in unit tests[/+] on Apr 23, 2025
  2. changed the title [-]Important RAM increase when ResourceResolvingStubDownloader is used in unit tests[/-] [+]Important RAM increase when stubs libraries are used in unit tests[/+] on Apr 23, 2025
  3. changed the title [-]Important RAM increase when stubs libraries are used in unit tests[/-] [+]Important RAM increase since 4.2.x when stubs libraries are used in unit tests[/+] on Apr 23, 2025
  4. added 2 commits that reference this issue on Apr 23, 2025
    c0ec13c
    1f9d839
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions