Memory implications of OmniFaces ViewScoped bean?

蓝咒 提交于 2019-12-01 22:29:22

I figured out the answers to these by adding a @PreDestroy method to each @ViewScoped bean, and logging when it gets destroyed. For others who might be curious about this:

For #1, a bean does not get destroyed if you navigate away from the page with a GET request, but then send a post request at a later time. That bean will stay in memory until the "maximum active view scopes" setting has been reached and it's the bean's turn to be destroyed, or the session has been invalidated.

For #2, class doesn't matter. You can have 5 instances of Class1, 5 instances of Class2, and 5 instances of Class3, and a new ViewScoped bean instance will destroy the oldest bean, given your threshold is 15.

For #3, it looks like the beans are destroyed once the session has been invalidated even if STATE_SAVING_METHOD is set to client.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!