<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
  <link rel="self" href="https://liferay.dev/es/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=114399812" />
  <subtitle>RE: Primefaces JSF VeiwScoped beans cleanup in session</subtitle>
  <id>https://liferay.dev/es/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=114399812</id>
  <updated>2026-05-18T21:53:05Z</updated>
  <dc:date>2026-05-18T21:53:05Z</dc:date>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118685091" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118685091</id>
    <updated>2020-03-06T22:39:26Z</updated>
    <published>2020-03-06T22:39:26Z</published>
    <summary type="html">In a few cases we could use request scope on certain portlets that were more transient.</summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2020-03-06T22:39:26Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118684750" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118684750</id>
    <updated>2020-03-06T22:38:02Z</updated>
    <published>2020-03-06T22:38:02Z</published>
    <summary type="html">No we are using session scope as described above which is working very well for us.</summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2020-03-06T22:38:02Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118684410" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118684410</id>
    <updated>2020-03-06T22:33:27Z</updated>
    <published>2020-03-06T22:33:27Z</published>
    <summary type="html">Hi Bill,&lt;br /&gt;Congratulations on going production! Glad to know that things are working well.&lt;br /&gt;Did you end up going with any @ViewScoped beans?&lt;br /&gt;&lt;br /&gt;Neil</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2020-03-06T22:33:27Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118685963" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118685963</id>
    <updated>2020-03-06T22:07:56Z</updated>
    <published>2020-03-06T22:07:56Z</published>
    <summary type="html">So we are in production now and supporting about 100 concurrent users daily performing thousands of transaction.  We did need to lighten up some of our payloads that but that said even this load we are running between 2 and 3 Gb of heap at peak time.  We have about 10 main portlets that provide the bulk of out data management needs to the end users.  We&amp;#39;re pretty happy with that.</summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2020-03-06T22:07:56Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114569497" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114569497</id>
    <updated>2019-08-01T21:08:06Z</updated>
    <published>2019-08-01T21:08:06Z</published>
    <summary type="html">But I really like using Liferay&amp;#39;s navigation.</summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2019-08-01T21:08:06Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114542781" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114542781</id>
    <updated>2019-07-31T14:53:55Z</updated>
    <published>2019-07-31T14:53:55Z</published>
    <summary type="html">Hi Bill,&lt;br /&gt;&lt;br /&gt;Thanks for posting your solution.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The only way for the bridge to determine that the user has clicked on a link with a URL to a different Liferay Portal page would be if the link were generated by the JSF portlet, which of course relies on the the bridge&amp;#39;s ExternalContext implementation to encode portlet URLs. You would need to display these links instead of the links generated by the Liferay Portal theme and/or nagivation portlet. That way, when the user clicks on a link, Mojarra would be made aware that the user has navigated away from the view and make any associated @ViewScoped beans available for garbage collection prior to redirecting to the desired Liferay Portal page URL.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;​​​​​​​Neil</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2019-07-31T14:53:55Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114508533" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114508533</id>
    <updated>2019-07-30T15:24:03Z</updated>
    <published>2019-07-30T15:24:03Z</published>
    <summary type="html">In the end I had to back off the use of ViewScoped managed beans and move to mainly using SessionScoped and in some cases RequestScoped.  I was getting way to many ViewScoped beans being created during a session that were not getting garbage collected until the session expired. It seem like everytime I went into a lifery page the had ViewScoped bean on I got a new bean added to my session.  Switching over to SessionScoped only gives me one bean in the session regardless of how times I go into the page that its deployed on. Also I was still able to reinitialize the new SessionScoped beans by adding the following tag to the their corresponding facelet::&lt;br /&gt;&lt;br /&gt; &amp;lt;f:metadata&amp;gt;&lt;br /&gt;       &amp;lt;f:viewAction action=&amp;#34;#{packagesView.onload}&amp;#34; /&amp;gt;&lt;br /&gt;&amp;lt;/f:metadata&amp;gt;&lt;br /&gt;&lt;br /&gt;The initialization code I had been executing  in the @PostConstruct method is now executed in the onload method shown and called above in my backing bean:&lt;br /&gt; @PostConstruct&lt;br /&gt;public void init() {&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;public void onload() {&lt;br /&gt;   loadAllPackages();&lt;br /&gt;   initTogglerList();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;A similar change was made to all my bean classes the I moved from ViewScoped to SessionScoped.&lt;br /&gt;​​​​​​​ &lt;br /&gt;So it seems that using ViewScoped beans with Liferay navigation is just not viable.  Would it be possible for the bridge to know that a Liferay navigation was performed which moved off a page that had a Viewscoped bean and then mark that bean for garbage collection?</summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2019-07-30T15:24:03Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114437701" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114437701</id>
    <updated>2019-07-25T14:08:41Z</updated>
    <published>2019-07-25T14:08:41Z</published>
    <summary type="html">My pleasure Bill. Glad to know that garbage collection is working fine.</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2019-07-25T14:08:41Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114434651" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114434651</id>
    <updated>2019-07-25T13:55:05Z</updated>
    <published>2019-07-25T13:55:05Z</published>
    <summary type="html">Thanks Neil for all this information.   We were looking at things yesterday jvisualvm and it looked like garbage collecting was working fine.  We are going to do further analysis today as well. Thanks again, your expertise is always appreciated.</summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2019-07-25T13:55:05Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114421669" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114421669</id>
    <updated>2019-07-24T19:10:54Z</updated>
    <published>2019-07-24T19:10:54Z</published>
    <summary type="html">When you wrote:&lt;blockquote&gt;&lt;br /&gt;    &amp;#34;get a new bean every time I go into the page&amp;#34;&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Are you seeing a new @ViewScoped bean instance every time you reload in the same browser tab? Or Is the new bean instance happening for each new browser tab?&lt;br /&gt;Regarding @SessionScoped, you are correct it should only get created once for each corresponding PortletSession.PORTLET_SCOPE.</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2019-07-24T19:10:54Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114421329" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114421329</id>
    <updated>2019-07-24T18:11:57Z</updated>
    <published>2019-07-24T18:11:57Z</published>
    <summary type="html">Yes but with session scope I shouldn&amp;#39;t get a new bean every time I go into the page like I&amp;#39;m seeing with view scope? </summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2019-07-24T18:11:57Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114420997" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114420997</id>
    <updated>2019-07-24T17:36:19Z</updated>
    <published>2019-07-24T17:36:19Z</published>
    <summary type="html">In general, config params like com.sun.faces.numberOfViewsInSession and com.sun.faces.numberOfLogicalViews should work the same in webapp and portlet environments.</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2019-07-24T17:36:19Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114420664" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114420664</id>
    <updated>2019-07-24T17:34:47Z</updated>
    <published>2019-07-24T17:34:47Z</published>
    <summary type="html">Beans annotated with @SessionScoped will not be made available for garbage collection until the session expires. So @ViewScoped is generally better than @SessionScoped because of that. As a recommended practice, you should use @RequestScoped over @ViewScoped/@SessionScoped because it will generally keep more memory available on the server. However, beans annotated with @RequestScoped could cause CPU utilization to increase under heavy load because the bean instances will have to be constructed and destroyed for each request.</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2019-07-24T17:34:47Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114419704" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114419704</id>
    <updated>2019-07-24T17:29:43Z</updated>
    <published>2019-07-24T17:29:43Z</published>
    <summary type="html">Hi Bill,I must have not communicated myself well, because I didn&amp;#39;t mean to give you the impression that @ViewScoped can&amp;#39;t be used in Liferay. It most certainly can be used in Liferay. We&amp;#39;ve actually done a lot of testing in this regard, making sure that @ViewScoped beans are cleaned up properly. For example, we have a &lt;a href="https://github.com/liferay/liferay-faces-bridge-impl/tree/master/issue/jsf-issues-portlet/src/main/webapp/WEB-INF/views/FACES-1470"&gt;test portlet that checks for regressions&lt;/a&gt; with an old memory leak bug we fixed many years ago.When I mentioned the &amp;#34;instanceable&amp;#34; feature, I was trying to communicate that Liferay permits you to have two instances of the same portlet on the same portal page. Each portlet will have its own PortletSession.PortletScope which makes it possible for them to function on the same page without interfering with one another.Beans annotated with @ViewScoped are *always* able to be garbage collected. They are made available for garbage collection after a navigation-rule executes, or when a session expires. And there shouldn&amp;#39;t be a new instance of a @ViewScoped bean every time you hit the page. Even if you reload the page, Mojarra should use the same @ViewScoped bean instance as the previous page load.OmniFaces should not be necessary. Regardless, OmniFaces was not designed with portlets in mind.Neil</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2019-07-24T17:29:43Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114417032" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114417032</id>
    <updated>2019-07-24T17:21:23Z</updated>
    <published>2019-07-24T17:21:23Z</published>
    <summary type="html">What about session and request scope? Would they have the same issues as view scope? Also I added the following settings in my web.xml:&lt;br /&gt;   &amp;lt;context-param&amp;gt;&lt;br /&gt;        &amp;lt;param-name&amp;gt;com.sun.faces.numberOfViewsInSession&amp;lt;/param-name&amp;gt;&lt;br /&gt;        &amp;lt;param-value&amp;gt;3&amp;lt;/param-value&amp;gt;&lt;br /&gt;    &amp;lt;/context-param&amp;gt;&lt;br /&gt;    &amp;lt;context-param&amp;gt;&lt;br /&gt;        &amp;lt;param-name&amp;gt;com.sun.faces.numberOfLogicalViews&amp;lt;/param-name&amp;gt;&lt;br /&gt;        &amp;lt;param-value&amp;gt;3&amp;lt;/param-value&amp;gt;&lt;br /&gt;    &amp;lt;/context-param&amp;gt;   &lt;br /&gt;Do these help at all?</summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2019-07-24T17:21:23Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114415734" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114415734</id>
    <updated>2019-07-24T16:55:19Z</updated>
    <published>2019-07-24T16:55:19Z</published>
    <summary type="html">It sounds like you are saying that we can&amp;#39;t use view scope in Liferay? Everytime I hit a page I&amp;#39;ll get a new Viewscoped bean that can&amp;#39;t be garbage collected? Man I&amp;#39;ve really misunderstood this whole thing.  What about using something like Omnifaces? Would that help at all? </summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2019-07-24T16:55:19Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114415397" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114415397</id>
    <updated>2019-07-24T16:08:19Z</updated>
    <published>2019-07-24T16:08:19Z</published>
    <summary type="html">As far as I know, Mojarra will only cause the @ViewScoped bean to be made available for garbage collection if you execute a navigation-rule to a different view that doesn&amp;#39;t have any @ViewScoped beans. Aside from that they will get cleaned up on session expiration.&lt;br /&gt;Under the hood, Liferay Faces Bridge keeps managed beans in PortletSession.PORTLET_SCOPE. And as I recall, Liferay Portal makes a distinction beyond that with &amp;#34;instanceable&amp;#34; portlets, so that each portlet instance has its own PortletSession.PORTLET_SCOPE. So even if you were to navigate from PageA to PageB, and each page had the same JSF portlet on them, they would be different portlet instances and Mojarra wouldn&amp;#39;t be able to cleanup the @ViewScoped beans.</summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2019-07-24T16:08:19Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114415062" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114415062</id>
    <updated>2019-07-24T15:34:31Z</updated>
    <published>2019-07-24T15:34:31Z</published>
    <summary type="html">I am going from a JSF Veiwscope page to another JSF ViewScope page, not and non-JSF portal page.  </summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2019-07-24T15:34:31Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114414730" />
    <author>
      <name>William Gosse</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114414730</id>
    <updated>2019-07-24T15:21:10Z</updated>
    <published>2019-07-24T15:21:10Z</published>
    <summary type="html">What about when I&amp;#39;m switching between pages using Liferay navigation.</summary>
    <dc:creator>William Gosse</dc:creator>
    <dc:date>2019-07-24T15:21:10Z</dc:date>
  </entry>
  <entry>
    <title>RE: Primefaces JSF VeiwScoped beans cleanup in session</title>
    <link rel="alternate" href="https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114413714" />
    <author>
      <name>Neil Griffin</name>
    </author>
    <id>https://liferay.dev/es/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114413714</id>
    <updated>2019-07-24T14:31:22Z</updated>
    <published>2019-07-24T14:31:22Z</published>
    <summary type="html">Hi Bill,&lt;br /&gt;Regarding the headManagedBean, yes that&amp;#39;s an implementation detail of Liferay Faces Bridge -- it needs to keep track of what it added to the &amp;lt;head&amp;gt;...&amp;lt;/head&amp;gt; section of the portal page.&lt;br /&gt;&lt;br /&gt;Regarding the PostConstruct approach, by removing it from the viewscope map, I&amp;#39;d be concerned that it would get unnecessarily re-created each time an f:ajax partial-submit occurs. Also, it seems like you&amp;#39;re getting closer and closer to @RequestScoped with that approach.&lt;br /&gt;&lt;br /&gt;The heart of the problem is that you are redirecting from a portal page with a JSF portlet on it to a different portal page that doesn&amp;#39;t have a JSF portlet from the same webapp context. That&amp;#39;s why Mojarra loses the ability to make the bean available for garbage collection. Instead, my recommendation would be, that when the Submit button is clicked, to execute a JSF action with a  navigation-rule that has ?faces-redirect=true to a view that does not have any @ViewScoped beans associated with it. Then, that page could then execute some JavaScript that does document.location=&amp;#34;...&amp;#34;; in order to do a client-initiated redirect to the non-JSF portal page.&lt;br /&gt;Neil </summary>
    <dc:creator>Neil Griffin</dc:creator>
    <dc:date>2019-07-24T14:31:22Z</dc:date>
  </entry>
</feed>
