<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Best practices to reduce the memory that is used by a single Html Dialog?</title><link>https://answers.axonivy.com/questions/2987/best-practices-to-reduce-the-memory-that-is-used-by-a-single-html-dialog</link><description>&lt;p&gt;We have a huge Html Dialog that uses around 80 MB memory per session on the engine side. The dialog is like a wrapper for the full application. It contains multiple tabs and modal dialogs &lt;code&gt;&amp;lt;p:dialog /&amp;gt;&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;Why is this Dialog consuming so much memory? Are there any best practices to build lightweight JSF dialogs?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/2987/best-practices-to-reduce-the-memory-that-is-used-by-a-single-html-dialog" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 20 Nov 2017 08:33:39 -0500</lastBuildDate><item><title>Comment by Reguel Wermelinger on Reguel Wermelinger's answer</title><link>https://answers.axonivy.com/questions/2987/best-practices-to-reduce-the-memory-that-is-used-by-a-single-html-dialog#2990</link><description>&lt;p&gt;From the ivy.core we want to lower the pain of these refactorings by solving the following issues:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://jira.axonivy.com/jira/browse/XIVY-2250"&gt;XIVY-2250: Support Primefaces Dialog Framework&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jira.axonivy.com/jira/browse/XIVY-2273"&gt;XIVY-2273: Execute ivy-component start method lazy and in JSF context&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Mon, 20 Nov 2017 08:33:39 -0500</pubDate><guid>https://answers.axonivy.com/questions/2987/best-practices-to-reduce-the-memory-that-is-used-by-a-single-html-dialog#2990</guid></item><item><title>Comment by SupportIvyTeam on Reguel Wermelinger's answer</title><link>https://answers.axonivy.com/questions/2987/best-practices-to-reduce-the-memory-that-is-used-by-a-single-html-dialog#2989</link><description>&lt;p&gt;one of our customers has 24 modal dialogs in multiple tabs. by applying the &lt;code&gt;rendered&lt;/code&gt; attribute as shown above, the memory usage on the engine side could be lowered from 80 MB to 25 MB.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">SupportIvyTeam</dc:creator><pubDate>Mon, 20 Nov 2017 08:09:04 -0500</pubDate><guid>https://answers.axonivy.com/questions/2987/best-practices-to-reduce-the-memory-that-is-used-by-a-single-html-dialog#2989</guid></item><item><title>Answer by Reguel Wermelinger</title><link>https://answers.axonivy.com/questions/2987/best-practices-to-reduce-the-memory-that-is-used-by-a-single-html-dialog/2988</link><description>&lt;p&gt;&lt;strong&gt;Why so much memory is used&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Invisible parts on the UI take memory on the engine because normally the HTML of these dialogs and tabs are eagerly loaded. The whole HTML code is generated and the view state is held on the engine. This requires processing power and memory. One can quickly identify such parts in a JSF dialog by using the Firefox + Inspect the page content. Loaded but not visible parts are shown as grayed out HTML in the console:&lt;/p&gt;
&lt;p&gt;&lt;img alt="sample of eagerly loaded content" src="https://answers.axonivy.com/upfiles/portal_processWidgetDialogs.png"&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to solve it&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Use the &lt;code&gt;rendered&lt;/code&gt; attribute to avoid eager loading of large UI parts that are not visible on the initial dialog. Load them on demand with Ajax requests.&lt;/p&gt;
&lt;p&gt;A lightweight solution for modal dialogs: In this example we have a button that controls the &lt;code&gt;rendered&lt;/code&gt; attribute of a &lt;code&gt;&amp;lt;p:dialog /&amp;gt;&lt;/code&gt;. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;h:form id="form"&amp;gt;
    &amp;lt;p:outputPanel id="address"&amp;gt;
        &amp;lt;p:commandButton value="Add Address" icon="fa fa-list-alt"
            actionListener="#{logic.showAddress(true)}" oncomplete="PF('addressDialog').show()"
            update="form:address" /&amp;gt;
        &amp;lt;p:dialog id="dialog" widgetVar="addressDialog" 
            header="Large sample component" 
            modal="true" visible="true" rendered="#{data.showAddress}" closable="false" &amp;gt;
                &amp;lt;ic:ch.ivyteam.htmldialog.demo.component.AddressComponent id="input" &amp;gt;
                    &amp;lt;p:commandButton value="close" 
                    actionListener="#{logic.showAddress(false)}" onclick="PF('addressDialog').hide()"
                    update="form:address"/&amp;gt;
                    &amp;lt;br/&amp;gt;
                &amp;lt;/ic:ch.ivyteam.htmldialog.demo.component.AddressComponent&amp;gt;
        &amp;lt;/p:dialog&amp;gt;
    &amp;lt;/p:outputPanel&amp;gt;
&amp;lt;/h:form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With the Weisshorn &lt;a href="https://developer.axonivy.com/download/sprint-release.html"&gt;Sprint 3 release&lt;/a&gt; of Axon.ivy the full sample can be analyzed in the &lt;code&gt;HtmlDialogDemos&lt;/code&gt;. Import &amp;gt; Axon.ivy &amp;gt; Sample Project &amp;gt; Html Dialog Demos &amp;gt; Component/lazyLoadComponent.ivp&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reguel Wermelinger</dc:creator><pubDate>Mon, 20 Nov 2017 07:56:00 -0500</pubDate><guid>https://answers.axonivy.com/questions/2987/best-practices-to-reduce-the-memory-that-is-used-by-a-single-html-dialog/2988</guid></item></channel></rss>