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

        Deryk Sinotte created issue -
        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
        Icefaces Administrator made changes -
        Field Original Value New Value
        issue.field.bugzillaimportkey 560 11825
        Ken Fyten made changes -
        Affects Version/s 1.5 [ 10027 ]
        Affects Version/s 1.0 [ 10024 ]
        Philip Breau made changes -
        Support Case References https://www.icesoft.ca:4443/supportilla/show_bug.cgi?id=4025
        Support Customer Ref. #s 694
        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.
        Ted Goddard made changes -
        Assignee Ted Goddard [ ted.goddard ] Mircea Toma [ mircea.toma ]
        Ken Fyten made changes -
        Fix Version/s 1.6DR#4 [ 10060 ]
        Fix Version/s 2.0 [ 10032 ]
        Assignee Priority P2
        Ken Fyten made changes -
        Assignee Priority P2 P1
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #13613 Fri Apr 20 11:45:44 MDT 2007 mircea.toma Dispose views when browser windows are closed -- ICE-556.
        Add notification facility so that application level code can free up resources (threads, connections....).
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/xmlhttp/PersistentFacesState.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/servlet/MainSessionBoundServlet.java
        Commit graph MODIFY /icefaces/trunk/icefaces/bridge/src/connection.async.js
        Commit graph MODIFY /icefaces/trunk/icefaces/bridge/lib/window.js
        Commit graph MODIFY /icefaces/trunk/icefaces/bridge/src/connection.js
        Commit graph MODIFY /icefaces/trunk/icefaces/bridge/src/application.js
        Commit graph MODIFY /icefaces/trunk/icefaces/bridge/lib/ajax.js
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/servlet/ServletView.java
        Commit graph ADD /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/core/DisposeViews.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/servlet/SessionDispatcher.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/env/ServletEnvironmentRequest.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/servlet/SingleViewServlet.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #13616 Fri Apr 20 13:59:51 MDT 2007 mircea.toma Change listener interface -- ICE-556.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/xmlhttp/PersistentFacesState.java
        Commit graph ADD /icefaces/trunk/icefaces/core/src/com/icesoft/faces/context/ViewListener.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/servlet/ServletView.java
        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...).
        Mircea Toma made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        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?
        Mircea Toma made changes -
        Fix Version/s 1.6 [ 10031 ]
        Fix Version/s 1.6DR#4 [ 10060 ]
        Mircea Toma made changes -
        Fix Version/s 1.6DR#4 [ 10060 ]
        Fix Version/s 1.6 [ 10031 ]
        Affects Version/s 1.6 [ 10031 ]
        Affects Version/s 1.5 [ 10027 ]
        Ken Fyten made changes -
        Issue Type Bug [ 1 ] Improvement [ 4 ]
        Ken Fyten made changes -
        Fix Version/s 1.6 [ 10031 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Priority P1
        Assignee Mircea Toma [ mircea.toma ]
        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: