ICEfaces
  1. ICEfaces
  2. ICE-556

Request-scoped bean remain in memory until the session expires

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.6DR#4, 1.6
    • Component/s: Framework
    • Labels:
      None
    • Environment:
      Operating System: All
      Platform: All

      Description

      If you run a plain JSF application that has request-scoped beans, the beans are
      garbage collected when the request is done. If you run the same application
      with ICEfaces, request-scoped beans remain in memory until the session expires.

        Activity

        Hide
        Ted Goddard added a comment -

        Need to create test case and investigate.

        Show
        Ted Goddard added a comment - Need to create test case and investigate.
        Hide
        Ken Fyten added a comment -

        Isn't this a potentially large memory leak?

        Show
        Ken Fyten added a comment - Isn't this a potentially large memory leak?
        Hide
        Ted Goddard added a comment -

        Checked in a test case that indicates that the leak is not serious: only one extra object remains after
        garbage collection and this may be due to the fact that ICEfaces maintains a request at all times.

        svn commit . -m "test case for request scope beans not being garbage collected (ICE-556)"
        Sending iraptor-webapp/conf/faces-config.xml
        Adding iraptor-webapp/src/bug560
        Adding iraptor-webapp/src/bug560/GarbageBean.java
        Sending iraptor-webapp/src/bug560/TestBean.java
        Adding iraptor-webapp/web/bug560.jsp
        Transmitting file data ....
        Committed revision 8698.

        The way this test case works is with two beans, an application scope bean that counts instances and a
        request scope bean that gets counted. The request scope bean increments the application scope bean
        when it is initialized and decrements the application scope bean when it is finalized. After garbage
        collection, only 1 instance of the request scope bean remains.

        Does this test case capture the correct circumstance? Perhaps the original incident had a memory leak
        within the application itself.

        Deryk, please comment on whether this test case is missing some aspect of the original reported
        configuration.

        Show
        Ted Goddard added a comment - Checked in a test case that indicates that the leak is not serious: only one extra object remains after garbage collection and this may be due to the fact that ICEfaces maintains a request at all times. svn commit . -m "test case for request scope beans not being garbage collected ( ICE-556 )" Sending iraptor-webapp/conf/faces-config.xml Adding iraptor-webapp/src/bug560 Adding iraptor-webapp/src/bug560/GarbageBean.java Sending iraptor-webapp/src/bug560/TestBean.java Adding iraptor-webapp/web/bug560.jsp Transmitting file data .... Committed revision 8698. The way this test case works is with two beans, an application scope bean that counts instances and a request scope bean that gets counted. The request scope bean increments the application scope bean when it is initialized and decrements the application scope bean when it is finalized. After garbage collection, only 1 instance of the request scope bean remains. Does this test case capture the correct circumstance? Perhaps the original incident had a memory leak within the application itself. Deryk, please comment on whether this test case is missing some aspect of the original reported configuration.
        Hide
        Ted Goddard added a comment -

        Deryk has created a test case to match his original observation. After some investigation, it appears that
        "concurrentDOMViews" is the culprit (changing this to false eliminates the leak). Further investigation is
        required to determine if the leak can be eliminated given the current implementation of
        concurrentDOMViews.

        Show
        Ted Goddard added a comment - Deryk has created a test case to match his original observation. After some investigation, it appears that "concurrentDOMViews" is the culprit (changing this to false eliminates the leak). Further investigation is required to determine if the leak can be eliminated given the current implementation of concurrentDOMViews.
        Hide
        Ted Goddard added a comment -

        ICEfaces maintains the request map as a "conversation" scope. With concurrentDOMViews it is not
        possible to distinguish between multiple browser windows open and reloads in the current window;
        hence multiple requests must be kept alive (potentially multiple conversations).

        We should investigate the following:

        • can a message be sent to the server upon page unload (even if this is unreliable, it would reduce the
          memory leak)
        • can unused views (remaining from reloaded windows not multiple windows) be detected through the
          fact that their connection over Ajax is stale? (missing heartbeats)

        Neither of these are simple memory leak fixes, however, so the safest action at this time may be to
        defer this bug fix to a later release.

        Show
        Ted Goddard added a comment - ICEfaces maintains the request map as a "conversation" scope. With concurrentDOMViews it is not possible to distinguish between multiple browser windows open and reloads in the current window; hence multiple requests must be kept alive (potentially multiple conversations). We should investigate the following: can a message be sent to the server upon page unload (even if this is unreliable, it would reduce the memory leak) can unused views (remaining from reloaded windows not multiple windows) be detected through the fact that their connection over Ajax is stale? (missing heartbeats) Neither of these are simple memory leak fixes, however, so the safest action at this time may be to defer this bug fix to a later release.
        Hide
        Ken Fyten added a comment -

        We'll have to document this in the KNOWN ISSUES for v1.0.1.

        Basically, when using concurrentDOMViews, reloading the page or opening the app.
        with more than one browser window will leave references to all request-scoped
        beans, which will prevent their being garbage collected until the session expires.

        Is this accurate? Also, is concurrentDOMViews enabled by default, and if so,
        should it be given this leak?

        Show
        Ken Fyten added a comment - We'll have to document this in the KNOWN ISSUES for v1.0.1. Basically, when using concurrentDOMViews, reloading the page or opening the app. with more than one browser window will leave references to all request-scoped beans, which will prevent their being garbage collected until the session expires. Is this accurate? Also, is concurrentDOMViews enabled by default, and if so, should it be given this leak?
        Hide
        Ted Goddard added a comment -

        concurrentDOMViews is not enabled by default.

        Each open browser window and each reload of the current browser page results in a new persistent
        request stored in the servlet session. Request-scope objects in these requests will not be garbage
        collected until the session expires.

        Show
        Ted Goddard added a comment - concurrentDOMViews is not enabled by default. Each open browser window and each reload of the current browser page results in a new persistent request stored in the servlet session. Request-scope objects in these requests will not be garbage collected until the session expires.
        Hide
        Ken Fyten added a comment -

        Ted,

        This was left over from 1.0.1, any change for 1.1? Can we / did we fix it?

        Show
        Ken Fyten added a comment - Ted, This was left over from 1.0.1, any change for 1.1? Can we / did we fix it?
        Hide
        Ted Goddard added a comment -

        As far as I know, this has not been fixed.

        Show
        Ted Goddard added a comment - As far as I know, this has not been fixed.
        Hide
        Ted Goddard added a comment -

        Testing with ICE-556 and ICEfaces 1.5.2 shows that the requestMap under ICEfaces is behaving
        according to design:

        With concurrentDOMViews true, "world" instances increase in number when the page is reloaded. This
        is due to the ICEfaces persistent request that remains due to the difficulty in distinguishing between
        newly opened windows and reloaded windows (we will be able to develop techniques to address this,
        but it is not a simple bug fix).

        With concurrentDOMViews false, a single "world" instance is created for each reload and persists,
        allowing the counter to be incremented even though the instance is in request scope.

        With standardRequestScope true, the counter cannot be incremented because a new "world" instance is
        created with each new request (as produced by clicking on the increment button).

        Show
        Ted Goddard added a comment - Testing with ICE-556 and ICEfaces 1.5.2 shows that the requestMap under ICEfaces is behaving according to design: With concurrentDOMViews true, "world" instances increase in number when the page is reloaded. This is due to the ICEfaces persistent request that remains due to the difficulty in distinguishing between newly opened windows and reloaded windows (we will be able to develop techniques to address this, but it is not a simple bug fix). With concurrentDOMViews false, a single "world" instance is created for each reload and persists, allowing the counter to be incremented even though the instance is in request scope. With standardRequestScope true, the counter cannot be incremented because a new "world" instance is created with each new request (as produced by clicking on the increment button).
        Hide
        Ted Goddard added a comment -

        There are at least two ways of improving the situation regarding this bug:

        • use a conversation scope (from, say, Seam)
        • detect browser window closing at the server and clean out requests corresponding to closed windows
        Show
        Ted Goddard added a comment - There are at least two ways of improving the situation regarding this bug: use a conversation scope (from, say, Seam) detect browser window closing at the server and clean out requests corresponding to closed windows
        Hide
        Ted Goddard added a comment -

        As a first step we should look at how to propagate window closing events to the server. If window closing cannot be reliably propagated over the network at the moment of window closing, we may want to accumulate viewNumbers of closed windows in a cookie to propagate the closing event on the next exchange. (This may also present complications, however, as the browser will allow the user to close many windows simultaneously, and it may be difficult to update the cookie coherently.)

        Ultimately, viewNumbers with unretrieved updates should be garbage collected.

        Show
        Ted Goddard added a comment - As a first step we should look at how to propagate window closing events to the server. If window closing cannot be reliably propagated over the network at the moment of window closing, we may want to accumulate viewNumbers of closed windows in a cookie to propagate the closing event on the next exchange. (This may also present complications, however, as the browser will allow the user to close many windows simultaneously, and it may be difficult to update the cookie coherently.) Ultimately, viewNumbers with unretrieved updates should be garbage collected.
        Hide
        Mircea Toma added a comment -

        Detect when browser windows are closed and disposed included views. Also, invoke listener to give a chance to applications to free up resources (such as connection, threads...).

        Show
        Mircea Toma added a comment - Detect when browser windows are closed and disposed included views. Also, invoke listener to give a chance to applications to free up resources (such as connection, threads...).
        Hide
        Alok Mittal added a comment -

        This bug has been marked as fixed in 1.6DR#4. Can you please provide more information on the fix? I believe the issue still exists with 1.6DR#5. Does it require any specific configuration?

        Show
        Alok Mittal added a comment - This bug has been marked as fixed in 1.6DR#4. Can you please provide more information on the fix? I believe the issue still exists with 1.6DR#5. Does it require any specific configuration?
        Hide
        Victor Jimenez added a comment -

        look like this is still hapening in the portlet version, request scope beans acts like session scope beans

        Show
        Victor Jimenez added a comment - look like this is still hapening in the portlet version, request scope beans acts like session scope beans

          People

          • Assignee:
            Unassigned
            Reporter:
            Deryk Sinotte
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: