Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » UIThread sometimes remains alive after session is invalidated
UIThread sometimes remains alive after session is invalidated [message #1809163] Wed, 10 July 2019 12:36 Go to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 235
Registered: March 2010
Location: France
Senior Member
Hello,

We discover our RAP application is suffering of a Memory leak for a while now.
The cause of the Memory Leak is UIThread remaining alive even after Http Session is invalidated.

Initially I wrongly though I was hitting something like this https://bugs.eclipse.org/bugs/show_bug.cgi?id=409843
but I think I understand the issue better now.

UIThread is supposed to be stopped with org.eclipse.rap.rwt.internal.service.UISessionImpl.valueUnbound(HttpSessionBindingEvent) which itself is called during
org.eclipse.equinox.http.servlet.internal.servlet.HttpSessionAdaptor.invalidate

I noticed when RAP application is loaded 2 attributes are registered in Container HttpSession:

* org.eclipse.equinox.http.parent.session.listener which is a org.eclipse.equinox.http.servlet.internal.servlet.HttpSessionAdaptor.ParentSessionListener
* equinox.http.org_eclipse_rap_rwt_osgi_internal_HttpContextWrapper-21org.eclipse.rap.rwt.internal.service.UISessionImpl#uisession:a5f93e09 which is the RAP UISessionImpl instance

When HttpSession is explicitely invalidated the container is calling removeAttribute on each attributes so valueUnbound is called on .ParentSessionListener which is supposed to shutdown UISession (by retrreiving it from session attribute

The issue as attributes is a map, sometimes, the container is removing equinox.http.org_eclipse_rap_rwt_osgi_internal_HttpContextWrapper-21org.eclipse.rap.rwt.internal.service.UISessionImpl#uisession:a5f93e09 before org.eclipse.equinox.http.parent.session.listener so when ParentSessionListener .valueUnbound is executing the UISession instance is not there anymore, so never shutdown.

Worse than that as the UISession is holding a reference to the HttpSession, the container never consider it as idle and the Session never timeout do the memory leak.

My guess is this behavior is occuring only with servlet bridge.

I have just added a jar in WEB-INF/lib of a legacy war (RAP application in servlet bridge) with


@WebListener
public class TestAttributeListener implements HttpSessionAttributeListener {

@Override
public void attributeAdded(HttpSessionBindingEvent event) {
}

@Override
public void attributeRemoved(HttpSessionBindingEvent event) {
System.out.println("Removed " + event.getName());
}

@Override
public void attributeReplaced(HttpSessionBindingEvent event) {
}

}


The RAP application is a workbench with an exit menu that is redirecting to a servlet that invalidate the http session

if "Removed org.eclipse.equinox.http.parent.session.listener" is dislpayed before Removed "equinox.http.org_eclipse_rap_rwt_osgi_internal_HttpContextWrapper-21org.eclipse.rap.rwt.internal.service.UISessionImpl#uisession:a5f93e09"
then everything is fine, but if Removed equinox.http.org_eclipse_rap_rwt_osgi_internal_HttpContextWrapper-21org.eclipse.rap.rwt.internal.service.UISessionImpl#uisession:a5f93e09 is displayed first, then there is the leak

Re: UIThread sometimes remains alive after session is invalidated [message #1809190 is a reply to message #1809163] Thu, 11 July 2019 07:46 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2327
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Arnaud,

is it reproducible with any workbench-based application? Any specific prerequisites to reproduce it with our Workbench Demo? Could you open a bugzilla to track the progress there?

Best regards,
Ivan
Re: UIThread sometimes remains alive after session is invalidated [message #1809193 is a reply to message #1809163] Thu, 11 July 2019 08:32 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2327
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Arnaud,

I think removing of "equinox.http.org_eclipse_rap_rwt_osgi_internal_HttpContextWrapper-21org.eclipse.rap.rwt.internal.service.UISessionImpl#uisession" will terminate the UI (see [1]). There is a HttpSessionBindingListener attached to UISessionImpl [2]. I don't understand how "org.eclipse.equinox.http.servlet.internal.servlet.HttpSessionAdaptor.ParentSessionListener" interferes with UISession shutdown.
BTW, which RAP version are you using? There are a lot of changes in the "org.eclipse.equinox.http.servlet" bundle recently. Is the issue reproducible with RAP 3.5 or 3.6?

[1] https://github.com/eclipse/rap/blob/master/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/service/UISessionImpl.java#L46
[2] https://github.com/eclipse/rap/blob/master/bundles/org.eclipse.rap.rwt/src/org/eclipse/rap/rwt/internal/service/UISessionImpl.java#L289

Regards,
Ivan
Re: UIThread sometimes remains alive after session is invalidated [message #1809250 is a reply to message #1809193] Fri, 12 July 2019 10:39 Go to previous messageGo to next message
Arnaud MERGEY is currently offline Arnaud MERGEYFriend
Messages: 235
Registered: March 2010
Location: France
Senior Member
Hello, I think my analysis of the issue is wrong. I do not understand why the UIThread remains alive. Maybe a race condition, as UI Thread does not consistently remains alive (sometime it correctly shutdown, sometime not) and putting breakpoints change behavior so the issue is not occuring.

The breakpoint give me the idea to move setMaxInactiveInterval(1); in a separated servlet change the menu action to navigate to this servlet instead of calling setMaxInactiveInterval directly, then I get no more stuck UIThread since then

I tested with old version of our app based on RAP neon, and still have it with RAP 2019-06

[Updated on: Fri, 12 July 2019 10:41]

Report message to a moderator

Re: UIThread sometimes remains alive after session is invalidated [message #1809877 is a reply to message #1809163] Thu, 25 July 2019 08:42 Go to previous message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2327
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
Hi Arnaud,

thanks for letting us know. If you have more insides or how to reproduce it, I'll be happy to assist and help to debug and fix it.

Regards,
Ivan
Previous Topic:Displaying AWT images
Next Topic:How to extend the application classpath of the equinox-based RAP launcher
Goto Forum:
  


Current Time: Thu Dec 12 23:02:42 GMT 2019

Powered by FUDForum. Page generated in 0.02291 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top