Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17527

CachingMetadataReaderFactory does not release shared resource cache after context refresh

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Complete
    • Affects Version/s: 5.0.10, 5.1.2
    • Fix Version/s: 5.0.11, 5.1.3
    • Component/s: Core
    • Labels:
    • Last commented by a User:
      true

      Description

      org.springframework.core.type.classreading.CachingMetadataReaderFactory.clearCache() was modified in Spring 5 to only clear the metaDataReaderCache of the LocalResourceCache instance type. When created with the constructor that takes a ResourceLoader as an argument, CachingMetadataReaderFactory will keep a strong reference on the Map that it got from the DefaultResourceLoader. This would be fine if DefaultResourceLoader.clearResourceCaches(), that is called after a context refresh, cleared the resourceCaches and the inner map that it contains, but this is not the case. So CachingMetadataReaderFactory.metaDataReaderCache remain in memory after context refresh.

      In our application this increased the memory footprint by about 100mb after we updated to Spring 5.

      A possible fix would be for CachingMetadataReaderFactory.clearCache() to set its metadataReaderCache to null if it's not an instance of LocalResourceCache.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              philjulien Philippe Julien
              Last updater:
              Spring Issues Spring Issues
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since last comment:
                3 years, 24 weeks, 2 days ago