Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primefaces Performance questions

Currently working with Primefaces 3.4.2 and we have noticed that if you navigate through our app using ajax, without reloading the page than we start to use a lot of memory. Currently using a program called CCDump to analyze the memory in firefox and noticed we where holding on to a lot of zombie dom objects. Narrowed down to focus on one object that is created by the following primefaces selectBooleanCheckbox

<p:selectBooleanCheckbox id="compareChkbx"
    value="#{cc.attrs.xProd.selected}" styleClass="selectBooleanCheckbox"
    rendered="#{dto.size > 1}" >
    <p:ajax event="change"  oncomplete="radioButtonSelected()" 
        listener="#{compareBean.onClickCompare(cc.attrs.xProd, cc.attrs.dto.partTerminology.partTerminologyId)}" update=":hform:lookupResults:pageInfo :hform:compareProducts:compareGroup @this" process="@this" />
</p:selectBooleanCheckbox>

And I am seeing hundreds of elements of this instance when I run the CC Analysis. If I "Show Graph" on one of the elements I get the following:

FragmentOrElement (xhtml) input id='lookupResults:CatResultList:0:aapPartType:list-by-cat:22:aapProd:aapProd:compareChkbx_input' http://localhost:8080/epcfe-web/main.xhtml 
JS Object (HTMLInputElement) 
FragmentOrElement (xhtml) div class='ui-helper-hidden-accessible' http://localhost:8080/epcfe-web/main.xhtml 
FragmentOrElement (xhtml) div id='lookupResults:CatResultList:0:aapPartType:list-by-cat:22:aapProd:aapProd:compareChkbx' class='ui-chkbox ui-widget selectBooleanCheckbox' http://localhost:8080/epcfe-web/main.xhtml 
nsChildContentList 
nsEventListenerManager 

The other thing I notice is that after navigating the application for a while I end up with hundereds javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces/eval/seq/xx in the firebug script tab

I think that there is a listener that is not getting deallocated that is connected to the div created by the p:selectBooleanCheckbox and I just wanted to know how I can release this object after reload that section of the page with ajax.

like image 839
Landister Avatar asked Oct 29 '13 22:10

Landister


People also ask

Why is JSF so slow?

JSF isnt slow but it has a overhead on the server side compared to JS frameworks like Angular. Thats much more CPU usage on the server side but lower CPU usage on client side. I would always build web applications with JSF but nothing social, which expectes like millions users a day.

What is PrimeFaces used for?

PrimeFaces provides the most advanced Client Side Validation for JavaServer Faces and Java EE. It is used to validate data at client side. It is compatible with Server Side Implementation and provides Advanced Bean Validation Integration.

Is PrimeFaces a JSF?

PrimeFaces, a popular JavaServer Faces (JSF) UI framework, can be used to quickly develop sophisticated applications for the enterprise or for standard websites. This article focuses on how to efficiently build data-driven applications for the enterprise using PrimeFaces.

How do I check my PrimeFaces version?

Just look in /META-INF/MANIFEST. MF file of the JSF impl JAR file. You can extract the JAR file with a ZIP tool. It's the Implementation-Version entry of the manifest file.


1 Answers

There has been some discussion about memory leaks whilst using PrimeFaces. "bayer-dba" posted this question on the PrimeFaces community forum:

http://forum.primefaces.org/viewtopic.php?f=3&t=25942&sid=caab96cad56a307f298b6267bf1936ef

Which led to this bug report and patch submission nearly a year ago:

http://code.google.com/p/primefaces/issues/detail?id=4848

I don't think this patch has made it into the trunk yet, but if you look at the code, you can see that it adds a dispose() method to each widget in order to clear up the widgets resources when removed.

You might find that applying this patch improves your situation with regards to Zombie DOM elements. Also, I notice that the patch makes reference to "PrimeFaces.widgetCache" when its clearing out resources, So you could try something similar in your script:

delete PrimeFaces.widgetCache[id];

_Pez

like image 151
underscorePez Avatar answered Sep 23 '22 19:09

underscorePez