[
https://issues.apache.org/jira/browse/MYFACES-4563?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17689201#comment-17689201
]
Volodymyr Siedlecki edited comment on MYFACES-4563 at 2/15/23 3:54 PM:
-----------------------------------------------------------------------
The code tries to retrieve the viewMap from the viewRoot, but, since the
attirubte isn't there, it's created with the UIViewRoot.getViewMap call (via
reflection, no args passed). So this leads to "this.getViewMap(true);" where
create is true.
[https://github.com/apache/myfaces/blob/4a996076a298b3767dab5e16fd312d5221e6b14a/api/src/main/java/jakarta/faces/component/UIViewRoot.java#L882]
{noformat}
UIViewRoot.getViewMap()
(/myfaces-api-4.0.0-RC5-SNAPSHOT.jar/jakarta.faces.component/UIViewRoot.class:882)
GeneratedMethodAccessor1449.invoke(Object,Object[]) (Unknown Source:-1)
Method.invoke(Object,Object[]) (/java.base/java.lang.reflect/Method.class:566)
_ComponentAttributesMap.getComponentProperty(PropertyDescriptorWrapper)
(/myfaces-api-4.0.0-RC5-SNAPSHOT.jar/jakarta.faces.component/_ComponentAttributesMap.class:658)
_ComponentAttributesMap.get(Object)
(/myfaces-api-4.0.0-RC5-SNAPSHOT.jar/jakarta.faces.component/_ComponentAttributesMap.class:317)
_ViewAttributeMap.get(Object)
(/myfaces-api-4.0.0-RC5-SNAPSHOT.jar/jakarta.faces.component/_ViewAttributeMap.class:98)
DebugUtils.printComponent(UIComponent,PrintStream,int,boolean,String)
(/org/apache/myfaces/util/DebugUtils.java:225){noformat}
was (Author: volosied):
The code tries to retrieve the viewMap from the viewRoot, but, since the
attirubte isn't there, it's created. UIViewRoot.getViewMap call. It calls
"this.getViewMap(true);" create is true.
[https://github.com/apache/myfaces/blob/4a996076a298b3767dab5e16fd312d5221e6b14a/api/src/main/java/jakarta/faces/component/UIViewRoot.java#L882]
{noformat}
UIViewRoot.getViewMap()
(/myfaces-api-4.0.0-RC5-SNAPSHOT.jar/jakarta.faces.component/UIViewRoot.class:882)
GeneratedMethodAccessor1449.invoke(Object,Object[]) (Unknown Source:-1)
Method.invoke(Object,Object[]) (/java.base/java.lang.reflect/Method.class:566)
_ComponentAttributesMap.getComponentProperty(PropertyDescriptorWrapper)
(/myfaces-api-4.0.0-RC5-SNAPSHOT.jar/jakarta.faces.component/_ComponentAttributesMap.class:658)
_ComponentAttributesMap.get(Object)
(/myfaces-api-4.0.0-RC5-SNAPSHOT.jar/jakarta.faces.component/_ComponentAttributesMap.class:317)
_ViewAttributeMap.get(Object)
(/myfaces-api-4.0.0-RC5-SNAPSHOT.jar/jakarta.faces.component/_ViewAttributeMap.class:98)
DebugUtils.printComponent(UIComponent,PrintStream,int,boolean,String)
(/org/apache/myfaces/util/DebugUtils.java:225){noformat}
> ViewScope Memory Leak When Trace Enabled
> ----------------------------------------
>
> Key: MYFACES-4563
> URL: https://issues.apache.org/jira/browse/MYFACES-4563
> Project: MyFaces Core
> Issue Type: Bug
> Affects Versions: 4.0.0-RC4
> Reporter: Volodymyr Siedlecki
> Priority: Major
> Attachments: image-2023-02-15-10-13-40-814.png
>
>
> I noticed a memory leak occurs when the myfaces trace is specified.
> !image-2023-02-15-10-13-40-814.png|width=348,height=355!
> After the map is cleared (i.e view changes), I see a new contextual storage
> created during the debug logging, but never removed.
> {noformat}
> ContextualStorage.<init>(BeanManager,boolean)
> (org/apache/myfaces/cdi/util/ContextualStorage.java:58)
> ViewScopeContextualStorage.<init>(BeanManager)
> (org/apache/myfaces/cdi/view/ViewScopeContextualStorage.java:36)
> ViewScopeContextualStorageHolder.newContextualStorage(String)
> (org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java:59)
> ViewScopeContextualStorageHolder.newContextualStorage(String)
> (org/apache/myfaces/cdi/view/ViewScopeContextualStorageHolder.java:32)
> AbstractContextualStorageHolder.getContextualStorage(String,boolean)
> (org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java:111)
> AbstractContextualStorageHolder.getContextualStorage(String)
> (org/apache/myfaces/cdi/util/AbstractContextualStorageHolder.java:93)
> ViewScopeContextualStorageHolder$Proxy$_$$_WeldClientProxy.getContextualStorage(String)
> (Unknown Source:-1)
> ViewScopeCDIMap.getStorage()
> (org/apache/myfaces/cdi/view/ViewScopeCDIMap.java:60)
> ViewScopeCDIMap.getCreationalContextInstances()
> (org/apache/myfaces/cdi/view/ViewScopeCDIMap.java:67)
> ViewScopeCDIMap.entrySet()
> (org/apache/myfaces/cdi/view/ViewScopeCDIMap.java:181)
> ViewScopeProxyMap.entrySet()
> (org/apache/myfaces/view/ViewScopeProxyMap.java:169)
> AbstractMap.toString() (/java.base/java.util/AbstractMap.class:544)
> DebugUtils.printAttribute(PrintStream,String,Object)
> (org/apache/myfaces/util/DebugUtils.java:373)
> DebugUtils.printComponent(UIComponent,PrintStream,int,boolean,String)
> (org/apache/myfaces/util/DebugUtils.java:226)
> DebugUtils.printView(UIViewRoot,PrintStream)
> (org/apache/myfaces/util/DebugUtils.java:147)
> DebugUtils.traceView(String,UIViewRoot)
> (org/apache/myfaces/util/DebugUtils.java:139)
> DebugUtils.traceView(String) (org/apache/myfaces/util/DebugUtils.java:119)
> LifecycleImpl.render(FacesContext)
> (org/apache/myfaces/lifecycle/LifecycleImpl.java:266)
> FacesServlet.service(ServletRequest,ServletResponse)
> (/myfaces-api-4.0.0-RC5-SNAPSHOT.jar/jakarta.faces.webapp/FacesServlet.class:225)
> ServletWrapper.service(ServletRequest,ServletResponse,WebAppServletInvocationEvent)
> (Unknown Source:1260){noformat}
> This problem only occurs when the trace is specified. The DebugUtils tries to
> print out the ViewMap and a new storage is created during this process.
> Is seems like there are two ViewMap (ViewScopeCDIMap) used since the storage
> for the cleared view is marked as deactivated and this other one created a
> new storage object?
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)