Memory implications of OmniFaces ViewScoped bean?

后端 未结 1 873
Happy的楠姐
Happy的楠姐 2021-01-20 19:54

From what I understand, ViewScoped beans only get destroyed when one of the following take place:

1) JSF sends a POST request to another page with something like a <

相关标签:
1条回答
  • 2021-01-20 20:33

    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.

    0 讨论(0)
提交回复
热议问题