<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Can I reduce the session-views that are held in the engine memory?</title><link>https://answers.axonivy.com/questions/2951/can-i-reduce-the-session-views-that-are-held-in-the-engine-memory</link><description>&lt;p&gt;The Axon.ivy ivy Engine caches 20 JSF Dialog views per session. As I have a huge dialog with lots of sub-Dialogs this consuming a lot of memory on the Engine. Can I somehow reduce the amount of cached views?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2951/can-i-reduce-the-session-views-that-are-held-in-the-engine-memory" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 03 Nov 2017 04:50:08 -0400</lastBuildDate><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/2951/can-i-reduce-the-session-views-that-are-held-in-the-engine-memory/2952</link><description>&lt;p&gt;This can easily be configured in the &lt;code&gt;/webapps/ivy/WEB-INF/web.xml&lt;/code&gt; of your engine. Just add the following parameter&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  &amp;lt;context-param&amp;gt;
    &amp;lt;param-name&amp;gt;org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION&amp;lt;/param-name&amp;gt;
    &amp;lt;param-value&amp;gt;10&amp;lt;/param-value&amp;gt;&amp;lt;!-- defaults to 20 if not set! --&amp;gt;
  &amp;lt;/context-param&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Why does JSF cache the views at all?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;These views are kept in the memory to allow the user open multiple dialogs in separate taps. Furthermore it also make back-navigation with the browser possible. At least while the previous dialog was not closed by executing a &lt;code&gt;close dialog&lt;/code&gt; event.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What is the drawback of this cache?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This cached views can grow big if you have huge dialog with many embedded sub-dialogs. Especially if you eagerly render all their contents even when they are not visible until the user opens a pop-up, sub-tab or similar. The size come from holding the complete view state and @ViewScoped managed beans. So you could run into OutOfMemoryErrors on the engine if you have many users on your engine that open huge dialogs.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;When to limit the cache?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you run out of memory on the engine. And you know that most of the time your users are only working with a single browser-tab. Then it could be sufficient to only cache the last 5 or 10 views.&lt;/p&gt;
&lt;p&gt;&lt;img alt="sample web.xml" src="https://answers.axonivy.com/upfiles/web.xml_lessViewsInSession.png"&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Fri, 03 Nov 2017 04:50:08 -0400</pubDate><guid>https://answers.axonivy.com/questions/2951/can-i-reduce-the-session-views-that-are-held-in-the-engine-memory/2952</guid></item></channel></rss>