The application died in OutOfMemory. Closed screen management beans are alive and R.I.P.
||javax.enterprise.context.RequestScoped||One HTTP request/response|
||javax.faces.view.ViewScoped||While the views are the same|
||javax.enterprise.context.ApplcationScoped||While the application is running|
||javax.enterprise.context.Dependent||Depends on the scope to which it was injected|
||javax.enterprise.context.ConversationScoped||You can specify the start and end arbitrarily|
||javax.enterprise.context.FlowScoped||From start to end of a predefined flow|
** It is convenient if
@ViewScoped is generated when the screen is opened and discarded when it is closed. ** **
You can give
@SessionScoped the information of the logged-in user and create a business screen with
You can also specify the number of
Views that a session holds in
/web.xml <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>sever</param-value> </context-param> <context-param> <param-name>com.sun.faces.numberOfLogicalViews</param-name> <param-value>20</param-value> </context-param> <context-param> <param-name>com.sun.faces.numberOfViewsInSession</param-name> <param-value>20</param-value> </context-param>
Know if it will be released if the upper limit is exceeded.
When I did something like that, the management bean of
@ViewScoped, which should have been destroyed, was so alive that the memory was crushed.
Apparently, the management bean of
@ViewScoped will not be released unless it has the following pattern.
Therefore, it survives in the following pattern.
Use OmniFaces @ViewScoped instead of the standard
Just use the
@ViewScoped annotation of ʻOmniFaces
and it will release it when you pick up the ʻunload event of your browser.
It is designed so as not to affect the default dependency as much as possible, so I wonder if it can be introduced just to use
I wondered if View would be managed on a screen-by-screen basis, but it's not a screen-based unit, but a component tree-based unit, so it's wrong to expect that it will be released when the screen is closed.
It is a trap behavior that it is not discarded even if the maximum number of logical views is exceeded.
~~ Don't hold the session for a long time & don't make it huge ~~
jsf-2 – Why @ViewScoped Beans that have expired are not destroyed until the session expires stack overflow : JSF 2.2 Memory Consumption: Why does Mojarra keep the ViewScoped Beans of the last 25 Views in Memory?