You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Jesús Pérez Alcaide (ISBAN JIRA)" <de...@myfaces.apache.org> on 2012/05/18 12:32:09 UTC

[jira] [Created] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

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

             Summary: 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)


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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Jesús Pérez Alcaide (ISBAN JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278760#comment-13278760 ] 

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

Leonardo, what I mean is that the real problem was introduced in the solution to MYFACES-3262, where a strong reference was used to hold the methods in _PropertyDescriptorHolder. If you use a SoftReference, like java.beans.PropertyDescriptor uses internally, the whole problem is solved.

So, if you change that, there is no problem with ClassLoaders, there is no need to do initialization nor cleanup code, and there is no memory leak.
                
> 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

       

[jira] [Updated] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Jesús Pérez Alcaide (ISBAN JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

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

    Status: Patch Available  (was: Open)
    
> 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)
>
> 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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13280999#comment-13280999 ] 

Leonardo Uribe commented on MYFACES-3549:
-----------------------------------------

Ok, I have checked it and you're right. In the solution you propose when the application is stopped, the classloader becomes weak/soft reachable, and two classes loaded by different classloaders has different hashcode, so they are considered different elements. 

But the controversy about the speed is not clear yet. The big question is if the soft reference used inside _PropertyDescriptorHolder is cleaned up when the server runs out of memory, which in theory will cause a similar effect, but in this case, _descriptor.getReadMethod() is a synchronized method and will cause an additional slowdown, in addition to the fact that _readMethodRef is not volatile, so an update will not be seen by other threads, and that will cause another slowdown. Anyway, all this stuff could happen in an exceptional use case.

Since the solution proposed by you sounds the most simple solution to the problem, I'll commit it. Thanks for the explanation.
                
> 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, MYFACES-3549-fix-hard-reference-map.patch, 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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Jesús Pérez Alcaide (ISBAN JIRA)" <de...@myfaces.apache.org>.
    [ 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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13280786#comment-13280786 ] 

Leonardo Uribe commented on MYFACES-3549:
-----------------------------------------

The problem here is in this part we are trying to balance two aspects of performance: speed and memory.

In this line of _PropertyDescriptorHolder:

private final Method _readMethod;

The "final" modifier is critical from concurrency perspective. It means once it is initialized it does not change but the most important part is all threads sharing this object will have the same value.

With the SoftReference:

private Reference<Method> _readMethodRef;

If multiple threads tries to access the reference at the same time and it was already collected by the GC, they will make many calls to get the method and the problem described in MYFACES-3262 occurs again.

So, at the end we have a slowdown of the server in saturation point, but now the concurrency effect is added. Which one is better? difficult to say it, because it is an exceptional case, right?

What I know is the current solution is a lot faster in typical situations. Note this part of the code is very sensitive to changes.

I know what you are proposing is correct from memory perspective, but the current solution is better from both speed and memory perspective. I'll attach a patch with the solution I'm thinking about to prevent the effect when the server is running out of memory. In that way, you'll see how it works.

There is another problem with the previous solution. Suppose you are sharing myfaces jars for two web application in the same container and one uses myfavoritejsflib-1.0.jar and the other one myfavoritejsflib-1.1.jar . Between these versions, there was a change and somebody added some properties to a component. Then, the application running  myfavoritejsflib-1.0.jar load a page containing that component first and later the other application. Since that map is shared by both, the first one will have the table for myfavoritejsflib-1.0.jar, which means it will not call the method on the component instance and it will use the attribute map. The user will not notice anything, but that should not happen. The new code fix that, holding different tables per ClassLoader, so two applications will not share the same table unless they share the same ClassLoader, which means, both should have the same dependencies.
                
> 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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Jesús Pérez Alcaide (ISBAN JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13281025#comment-13281025 ] 

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

Thank you Leonardo for your valuable comments.

I spent the whole morning looking for information about the final and volatile keywords. I think making _readMethodRef volatile could reduce the number of calls to _descriptor.getReadMethod() when the soft reference is cleared, but this only occurred when the server is about to run out of memory.

In this scenario it is uncertain whether the server is able to recover enough memory to continue execution, so I don't know whether it is worthwhile to optimize the code for that delicate situation. I think it is reasonable to optimize the typical case, and that's what I intend with my proposal.

                
> 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)
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.14, 2.1.8
>
>         Attachments: AAA_patch_PropertyDescriptor_MyFaces217.jar, MYFACES-3549-fix-hard-reference-map.patch, 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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278797#comment-13278797 ] 

Leonardo Uribe commented on MYFACES-3549:
-----------------------------------------

But the code doesn't solve the behavior described in MYFACES-3510. First of all, the current code, the previous code, and the code proposed here has no memory leaks. What we want here is a way to prevent collect that map when the server is running out of memory, but release it as soon as the app is undeployed. Remember in these days it is possible to find different web applications sharing the same myfaces jars, so we also don't want situations where some classloader is not released because other application has a strong reference to the map and through that way to the discarded classloader.
                
> 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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13280824#comment-13280824 ] 

Leonardo Uribe commented on MYFACES-3549:
-----------------------------------------

Ok, it is done (see MYFACES-3549-fix-hard-reference-map.patch). This ensure the map reference that also contains SoftReference will not be collected by the GC until the application stops or is undeployed. I tested it with YourKit and Tomcat 7, and it works well. Remember, an object is collected only when there are no hard references to it, so the SoftReference will not be cleared until the hard reference is cleared.

As long as the application is still running, the classloader will be reachable and the WeakHashMap holding the classloader will not be cleared too. 

Now we have all issues solved, including a very good performance in this part and a very nice memory handling.

Note that get the ClassLoader using:

Thread.currentThread().getContextClassLoader()

Is cheap. See this comparison I did:

http://lu4242.blogspot.com/2012/05/understandingjsf-2-and-wicket.html

You can see that 2.1.7 has better response times than 2.1.6, and that has sense because get context classloader only requires a variable assigment to get it.

If no objections I'll commit this code soon. Thanks a lot for the feedback, it is a valuable contribution.
                
> 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, MYFACES-3549-fix-hard-reference-map.patch, 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

       

[jira] [Updated] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe updated MYFACES-3549:
------------------------------------

       Resolution: Fixed
    Fix Version/s: 2.1.8
                   2.0.14
         Assignee: Leonardo Uribe
           Status: Resolved  (was: Patch Available)

Thanks to Jesús Pérez Alcaide for provide this patch.
                
> 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)
>            Assignee: Leonardo Uribe
>             Fix For: 2.0.14, 2.1.8
>
>         Attachments: AAA_patch_PropertyDescriptor_MyFaces217.jar, MYFACES-3549-fix-hard-reference-map.patch, 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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278755#comment-13278755 ] 

Leonardo Uribe commented on MYFACES-3549:
-----------------------------------------

One idea to fix the problem is add some initialization code in myfaces to grab the map with a hard reference and clean this reference only when the application is shutdown. If myfaces init code can't take the reference by a security or classloading constraint, the app will work as now, which is ok.
                
> 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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Jesús Pérez Alcaide (ISBAN JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13280901#comment-13280901 ] 

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

The supposition that you do in your previous comment [0] is incorrect.

If you put the 2 versions of the library associated with the server (and therefore available to all applications deployed on that server), both applications will use the same version of the library, and this version will be the one that is found first in the Classpath. This scenario is invalid if you want to use different versions of the same library in different applications.

If you put each version of the library associated with each application (for example, in their WEB-INF/lib directory), then each application will use only their version of the library, because each application uses a different ClassLoader. See [1].

In this second scenario, 2 classes loaded from different ClassLoader *are not equal* [2], although these classes have the same name. Therefore, the map will have two entries, one for each class loaded from each ClassLoader, and then it does not exist the problem you mentioned.

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

[1] http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html

[2] http://docs.oracle.com/javase/specs/jvms/se5.0/html/ConstantPool.doc.html#78621

                
> 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, MYFACES-3549-fix-hard-reference-map.patch, 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

       

[jira] [Commented] (MYFACES-3549) Alternative solution to bugs MYFACES-3262 and MYFACES-3510

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-3549?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278753#comment-13278753 ] 

Leonardo Uribe commented on MYFACES-3549:
-----------------------------------------

The previous code has a logic related to classloaders. The idea is simple, if you have multiple web application using the same myfaces classes (for example tomcat server with myfaces jars into its base lib folder), and one of them is undeployed, that classloader cannot be unloaded from memory because there is a reference to them through the Class instance. The effect seen was that only when all values in the WeakHashMap are reclaimed, the classloader is released. It is not a memory leak, but it can easily fill the memory with garbage, because the gc needs to find the right values to reclaim. I remember this effect was discussed in MYFACES-2942, long time ago. 






                
> 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