Our application is developed based on JDeveloper 11 and we have used VIEW scope extensively in our application.
We have monitored our application with JProfile and identified that the View Scope instances are not getting released even after we navigate from the respective pages to another and the instances getting added whenever we come back to the same page.
This is creating big impact on the heap side.
Can you please advise us how to rectify the issue?
Thanks in advance.
It is not an issue (I downloaded an evaluation copy of JProfiler to check it out).
JProfiler shows all instances of the class in memory (including unreferenced ones). If you force run the garbage collector (there is a button in JProfiler to do so), you will see the instance count go back down to the "correct" number.
Note: JDeveloper has a memory profiler that appears to show the number "correctly"
PageFlowScopes are not released explicitly when the user leaves the corresponding taskflow or JSF page. They remain in a PageFlowScope cache in order to be available if the user navigates back by clicking the browser's Back button. This cache is of a fixed size (which is configurable), so the PageFlowScopes are released implicitly when they fall out of the cache (e.g. when a corresponding number of new entries are put into the cache). Please, have a look about the parameter <tt><page-flow-scope-lifetime></tt> here: http://myfaces.apache.org/trinidad/devguide/configuration.html#trinidad-config.xml
I suspect that the situation with the ViewScopes is similar (i.e. they are cached too and will be released when a corresponding number of new entries is put into the cache), so you should not expect the ViewScope of the page that you have just left to be released and garbage collected immediately. Please, have a look here about view state caching, although it is related to the ViewScopes indirectly: http://docs.oracle.com/cd/E21764_01/web.1111/b31973/ap_config.htm#CEGCIDAB