[ 
https://jira.codehaus.org/browse/MNG-5205?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=306891#comment-306891
 ] 

Kristian Rosenvold commented on MNG-5205:
-----------------------------------------

The cache is very much an "inner loop" type of optimization, where an extreme 
hotspot has been identified and "solved" at the innermost level. Which actually 
means the "copyFields" stuff happening in Class#getDeclaredFields is not really 
desirable.

I reworked the interpolation strategy in r1376085 (and did remove one of the 
caches), unfortunately this rework was also an "inner loop" type of 
optimization. After thinking some more about this whole problem I think I have 
come across a solution that applies at a slightly higher level, which should 
reduce the hotness of this code considerably and may make the caching at this 
level less necessary. In all circumstances I'll make sure we use at least a 
SoftReference to avoid the leaks.


                
> Memory leak in StringSearchModelInterpolator
> --------------------------------------------
>
>                 Key: MNG-5205
>                 URL: https://jira.codehaus.org/browse/MNG-5205
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Inheritance and Interpolation
>    Affects Versions: 3.0.3
>            Reporter: Jesse Glick
>            Assignee: Kristian Rosenvold
>            Priority: Minor
>             Fix For: 3.0.5
>
>         Attachments: x.diff
>
>
> {{StringSearchModelInterpolator}} abuses {{WeakHashMap}}; the {{Field}} 
> values of {{fieldsByClass}} hold hard references to the {{Class}} keys, 
> making it useless. Thus if you passed any {{Class}} to it, that class and its 
> {{ClassLoader}} and the transitive static graph therefrom would never be 
> collectible.
> Anyway a cache is unnecessary, since {{Class}} does its own caching of fields!
> Also removing the ill-conceived {{fieldIsPrimitiveByClass}} - not a memory 
> leak, but likely unnecessary complication.
> The class is deprecated anyway, but just in case it is used by someone it 
> should be fixed.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to