UIThread sometimes remains alive after session is invalidated [message #1809163] |
Wed, 10 July 2019 08:36  |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.24890 seconds