You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ravi Kapoor <ra...@gmail.com> on 2010/06/07 09:04:10 UTC

manually removing page state cache

Hello everybody,
I need help with a memory issue.

As we know, trinidad caches page state for each page in memory. Since we are
not using back buttons and do not need to store page state in memory. There
was a defect related to this as well (
https://issues.apache.org/jira/browse/TRINIDAD-1193). However the fix does
not work for me for 2 reasons:

1. We are using trinidad version 1.0.7 (sorry we cannot upgrade due to
corporate cowardliness).
2. I tested with 1.0.10 version and memory is still not freed. I do not know
why. Maybe due to our complicated architecture, trinidad is not able to
correctly identify 'navigate away' event to free up old page state.

After this, I inserted following code before page transition in our
application. This code actually caused a much bigger memory leak rather than
fixing it.

*FacesContext fc = FacesContext.getCurrentInstance();
UIViewRoot vr = fc.getViewRoot();
RenderKit kit = fc.getRenderKit();
ResponseStateManager rsm = kit.getResponseStateManager();
Object token = rsm.getTreeStructureToRestore(fc, vr.getViewId());

TokenCache cache3 = TokenCache.getTokenCacheFromSession(fc,
"org.apache.myfaces.trinidadinternal.application.VIEW_CACHE", false, 1);
cache3.clear(fc.getExternalContext().getSessionMap());

TokenCache tc1 = TokenCache.getTokenCacheFromSession(fc,
"org.apache.myfaces.trinidadinternal.application.VIEW_CACHE", false, 1);
tc1.removeOldEntry((String) token, fc.getExternalContext().getSessionMap())
fc.getExternalContext().getSessionMap().remove("org.apache.myfaces.trinidadinternal.application.VIEW_CACHE."
+ token);
*

Can you help me fix this code so that I can clean up old memory without a
memory leak. Any other ideas area also welcome.

Thanks
Ravi