[ https://issues.apache.org/jira/browse/MRESOLVER-250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17521608#comment-17521608 ]
Frank Upgang commented on MRESOLVER-250: ---------------------------------------- Thanks for fixing this! Just tested the 1.8.0-SNAPSHOT containing the fix and I can verify the memory improvement in my use case. !image-2022-04-13-12-35-15-582.png! This run resolves about 250 dependency trees (verbose) containing some large monolithic applications. (We index all dependency trees to immediately answer questions like "Who is still using unsupported versions of spring?" or "Which services are affected by log4shell or spring4shell?") > Usage of descriptors map in DataPool prevents gargabe collection > ---------------------------------------------------------------- > > Key: MRESOLVER-250 > URL: https://issues.apache.org/jira/browse/MRESOLVER-250 > Project: Maven Resolver > Issue Type: Bug > Components: Resolver > Affects Versions: 1.6.3 > Environment: Linux, Java 11 > Reporter: Frank Upgang > Priority: Major > Attachments: image-2022-04-12-16-36-19-783.png, > image-2022-04-12-16-36-49-903.png, image-2022-04-13-12-35-15-582.png > > > 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. -- This message was sent by Atlassian Jira (v8.20.1#820001)