ViewScoped memory leak

Splash Forums PrettyFaces Users ViewScoped memory leak


This topic contains 2 replies, has 2 voices, and was last updated by  brettw 5 years, 11 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #27346


    I’ve come across a memory leak issue in my JSF 2.2 application (using rewrite 2.0.12). I’ve found that using the <url:link /> tag means that view scoped beans on a page will not be garbage collected when the url:link is used to navigate away from the page. I’ve witnessed this in JProfiler and forcing a garbage collection will not allow the bean to be cleaned up. If I use a standard JSF <h:commandButton action=”X” /> component to navigate away from the same page, the bean is then garbage collected. Is this a known issue with pretty faces? Have I missed something obvious? I can provide specific code if needed but I thought this one might be a misunderstanding of how pretty faces works.
    Thanks for any feedback/help.

    • This topic was modified 5 years, 11 months ago by  brettw.
    • This topic was modified 5 years, 11 months ago by  brettw.

    I don’t think this has anything to do with PrettyFaces/Rewrite.

    How and when view scoped beans are released depends on the how the JSF implementation handles state saving. Typically a JSF implementation keeps a few views (and therefore also the view scope) around for some time because the use may click the back button and then trigger some action on the old page. For MyFaces the number of views saved this way is configurable. There is also an option which allows you to configure how POST-Redirect-GET scenarios are handled in MyFaces.

    The h:link component renders a standard HTML link. If you click it, the JSF implementation doesn’t even know that you clicked it. It will just see a request from the browser for the new URL. So this may explain why the view scope is kept alive longer. If you use something like a h:commandButton, JSF knows that it is a postback to the old view. So after navigating away it COULD kill the view scope of the old view.



    Thanks Christian, yes that all makes sense.

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.