eclipse-ee4j / mojarra

Mojarra, a Jakarta Faces implementation
Other
159 stars 109 forks source link

UIData might save many states of components which are in a default state #5229

Closed jepsar closed 1 year ago

jepsar commented 1 year ago

Sorry for not following the template, but I think I can best describe this issue by referring to issue https://github.com/primefaces/primefaces/issues/7369 and PR https://github.com/primefaces/primefaces/pull/10014 of PrimeFaces. PrimeFaces basically uses a copy of Mojarra UIData, so the same issue might manifest here.

Some background: we have an application running OOM every now and then. Profiling showed that most of the memory was consumed by SavedState objects. After debugging, it turned out that UIData was storing many instances which were in default state. This for example happens when you use a custom filter in a p:column tag. For each table row, an instance is saved. The amount of saved entries drops drastically when you check on the default / empty state of components.

Screenshot_2023-04-03_at_16 20 05

image

BalusC commented 1 year ago

so the same issue might manifest here

I've analyzed this and no, it doesn't manifest. The difference is that UIData in Mojarra has this block in saveDescendantState(UIComponent, FacesContext) which is absent in PrimeFaces one and it has in the end exactly the same effect:

            if (state.hasDeltaState()) {
                getStateHelper().put(PropertyKeys.saved, clientId, state);
            } else if (saved != null) {
                getStateHelper().remove(PropertyKeys.saved, clientId);
            }

Based on source code revision history it was added with this commit https://github.com/javaee/mojarra/commit/20d8c0e603f5568058e96bb2b3300bc7cf2bd28c during https://github.com/eclipse-ee4j/mojarra/issues/2969.

Nonetheless thank you very much for reporting a potential performance problem!