myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesús Pérez Alcaide (ISBAN) (JIRA) <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510
Date Mon, 21 May 2012 11:16:40 GMT

    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13280084#comment-13280084
] 

Jesús Pérez Alcaide (ISBAN) commented on MYFACES-3549:
------------------------------------------------------

Hi Leonardo,

Let me correct you, the code used to fix the bug MYFACES-3262 does caused a memory leak, because
by using a strong reference to the Method, it was making the ClassLoader strongly reachable.

To fix that, we open the bug MYFACES-3510, but instead of fixing _PropertyDescriptorHolder
class, the class _ComponentAttributesMap was modified. But this change in _ComponentAttributesMap
is unnecessary if you add a soft reference in class _PropertyDescriptorHolder.

That's what I propose. Change the solution given in MYFACES-3262 by adding a SoftReference.
And undo the changes made in MYFACES-3510, since they are unnecessary now.

Thus, there would be no way to keep a strong reference to the ClassLoader, since the class
_PropertyDescriptorHolder has a SoftReference and then the ClassLoader is softly reachable.

Similarly, in the class _ComponentAttributesMap there would be no way to keep a strong reference
to the ClassLoader as the static map used for caching instances of _PropertyDescriptorHolder
is a WeakHashMap instance, which uses internally a WeakReference for the keys. As the key
is the component's Class, the ClassLoader that loaded this Class is weakly reachable.

If you intended to prevent the map is collected when the server runs out of memory, that's
not what you're getting with the current code for version 2.1.7, since you are using a WeakHashMap
keyed on ClassLoader and, as has already been said, internally uses a WeakReference for the
keys. Therefore, when the server runs out of memory, the garbage collector will clear all
weak references and, therefore, will clear the entry of this map.

Still, I do not think that this behavior is desirable because it has been shown that getting
the current ClassLoader harms the performance of each request. This would be damaging the
usual case (when the server has enough memory) in favor of the exceptional case (when the
server runs out of memory).

                
> Alternative solution to bugs MYFACES-3262 and MYFACES-3510
> ----------------------------------------------------------
>
>                 Key: MYFACES-3549
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3549
>             Project: MyFaces Core
>          Issue Type: Improvement
>    Affects Versions: 2.1.7
>            Reporter: Jesús Pérez Alcaide (ISBAN)
>         Attachments: AAA_patch_PropertyDescriptor_MyFaces217.jar, MyFaces3262_PropertyDescriptorHolder.patch,
MyFaces3510_AbstractFacesInitializer.patch, MyFaces3510_ComponentAttributesMap.patch
>
>
> I would like to propose an alternative solution to bugs MYFACES-3262 and MYFACES-3510,
which consists in rollback the changes made in MYFACES-3510 and modify the solution given
in MYFACES-3262 by adding a soft reference to the methods held in the class _PropertyDescriptorHolder.
> This alternative solution fixes MYFACES-3262 and avoids the performance loss caused by
MYFACES-3510.
> More information in this email:
> http://markmail.org/message/xh66wlte6luqn63d

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

       

Mime
View raw message