0 Replies Latest reply on Aug 1, 2011 9:29 PM by kpalania75

    Reducing JSF Memory Footprint: Relationship between View State and Bean Scope

    kpalania75

      I am working on a RichFaces-based JSF application that has com.sun.faces.numberOfViewsInSession and com.sun.faces.numberOfLogicalViews parameters set to 1 but has most of the managed beans set to a "session" scope. If reducing the memory footprint is the prime objective (with no significant deterioration to the page rendering times as well), what would be a better option?

      • Changing the scope to "request" so that the view state is not held for too long (unlike when the scope is set to "session").

      I read somewhere that the scope of the beans could have a bearing on the size of the view (and "request" scoped beans may not necessarily be available for GC at the end of the request). I have seen a performance degradation in this case, straightaway though.

      • Changing the scope to "application" since a number of pages are user-agnostic and don't really change based on the authenticated user. The application scope would result in a singleton and therefore, would the overall memory associated with a bean would be significantly lower as it is not tied to a user?

      Also, would this result in the JSF View lingering around for a little too long? If yes, this would make it worse than how it is currently with the session scoped beans.

      Last but not the least, there are multiple forms within a view. Could this play a role as well in increasing the memory footprint?