Uploaded image for project: 'Maven Resolver'
  1. Maven Resolver
  2. MRESOLVER-250

Usage of descriptors map in DataPool prevents gargabe collection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.3
    • 1.8.0
    • Resolver
    • None
    • Linux, Java 11

    Description

      While resolving a lot of rather huge dependency trees in my application I observed a high heap consumption by org.eclipse.aether.internal.impl.collect.DataPool.
      The DataPool holds Descriptor references in a WeakHashMap.

      Unfortunately, the key is indirectly referenced by the value - thus is is never eligible for garbage collection.

      The key is an Artifact taken from the ArtifactDescriptorRequest.
      The value is an ArtifactDescriptorResult which references the Artifact (key) and the ArtifactDescriptorRequest.

      To fix this the value should be wrapped in a WeakReference or SoftReference.
      This is what the ObjectPools does which is used by the DataPool for Artifacts and Dependencies.

       

      My use case is an application that indexes the dependency trees of all our services. Therefore there is a lot of dependency resolution when building the index.
      I implemented a workaround by wrapping the value in a WeakReference. The memory consumption is significantly lower afterwards as shown by the attached screenshots.

       

      If desired, I would create a pull request, but I haven't set up a maven workspace yet.

      Attachments

        1. image-2022-04-12-16-36-19-783.png
          60 kB
          Frank Upgang
        2. image-2022-04-12-16-36-49-903.png
          57 kB
          Frank Upgang
        3. image-2022-04-13-12-35-15-582.png
          57 kB
          Frank Upgang

        Issue Links

          Activity

            People

              cstamas Tamas Cservenak
              fupgang Frank Upgang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: