Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » memory leak in rap e4?
memory leak in rap e4? [message #1732494] Tue, 17 May 2016 16:42 Go to next message
Peter Kullmann is currently offline Peter KullmannFriend
Messages: 240
Registered: July 2009
Senior Member
I think that the incubator e4 rap is leaking: I have a simple application with a lifecycle class like this:

public class TestApplication {

    @PostContextCreate
    public void start(Display display, IEclipseContext context) {
        context.set(SessionContext.class, new SessionContext());
    }

}


After refreshing the browser a few times I end up with as many SessionContext instances as I refreshed. Forcing garbage collection doesn't help.

Analyzing the heap in memory analyzer I think that E4Application$2 is being kept alive - and with this the whole eclipsecontext is kept.

Is there an easy fix? Something I could null out whenever a session ends?

Thanks
Peter
Re: memory leak in rap e4? [message #1732603 is a reply to message #1732494] Wed, 18 May 2016 06:05 Go to previous messageGo to next message
Peter Kullmann is currently offline Peter KullmannFriend
Messages: 240
Registered: July 2009
Senior Member
In order to get some memory back I hacked the following in PartRenderingEngine:run():

display.addListener(SWT.Dispose, new Listener() {
  @Override
  public void handleEvent(org.eclipse.swt.widgets.Event event) {
    String instanceId = (String) runContext.get(E4Application.INSTANCEID);
    try {
      BundleContext bc = FrameworkUtil.getBundle(getClass()).getBundleContext();
      Collection<ServiceReference<IWorkbench>> refs = bc.getServiceReferences(IWorkbench.class,
          "(id=" + instanceId + ")");
      if (!refs.isEmpty()) {
        ServiceReference<IWorkbench> serviceReference = refs.iterator().next();
        IWorkbench workbench = bc.getService(serviceReference);
        if (workbench != null) {
          workbench.close();
        }
      }
    } catch (InvalidSyntaxException e) {
      throw new RuntimeException(e);
    }
    runContext.dispose();
  }
});


This frees my session stuff but leaves the whole ui model alive (eg ApplicationImpl, WindowImpl and so on).
Re: memory leak in rap e4? [message #1732682 is a reply to message #1732603] Thu, 19 May 2016 07:28 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Can you please file a bug. So that we can track that down.

Tom

On 18.05.16 08:05, Peter Kullmann wrote:
> In order to get some memory back I hacked the following in
> PartRenderingEngine:run():
>
>
> display.addListener(SWT.Dispose, new Listener() {
> @Override
> public void handleEvent(org.eclipse.swt.widgets.Event event) {
> String instanceId = (String) runContext.get(E4Application.INSTANCEID);
> try {
> BundleContext bc =
> FrameworkUtil.getBundle(getClass()).getBundleContext();
> Collection<ServiceReference<IWorkbench>> refs =
> bc.getServiceReferences(IWorkbench.class,
> "(id=" + instanceId + ")");
> if (!refs.isEmpty()) {
> ServiceReference<IWorkbench> serviceReference =
> refs.iterator().next();
> IWorkbench workbench = bc.getService(serviceReference);
> if (workbench != null) {
> workbench.close();
> }
> }
> } catch (InvalidSyntaxException e) {
> throw new RuntimeException(e);
> }
> runContext.dispose();
> }
> });
>
>
> This frees my session stuff but leaves the whole ui model alive (eg
> ApplicationImpl, WindowImpl and so on).
Re: memory leak in rap e4? [message #1732810 is a reply to message #1732682] Fri, 20 May 2016 11:36 Go to previous messageGo to next message
Peter Kullmann is currently offline Peter KullmannFriend
Messages: 240
Registered: July 2009
Senior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=494141
Re: memory leak in rap e4? [message #1741260 is a reply to message #1732810] Wed, 24 August 2016 08:56 Go to previous messageGo to next message
Eclipse UserFriend
Hello,
I am replying to this post because the problem is still there. I close my sessions but the model is still alive in the JVM along with the objects that were created inside MParts.
https://www.eclipse.org/forums/index.php/t/262741/
Re: memory leak in rap e4? [message #1741262 is a reply to message #1741260] Wed, 24 August 2016 09:13 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I think the root cause is that we are not destroying the service context
upon shutdown.

The problem is that I'm currently so swapped with work that I can not
fix it in my free time! If you come up with a fix feel provide a
gerrit-review and I'll certainly merge it.

Tom
Re: memory leak in rap e4? [message #1741287 is a reply to message #1741262] Wed, 24 August 2016 11:31 Go to previous message
Eclipse UserFriend
Yes that is exactly that. When closing an MPart with the mouse, objects are destroyed (since RAP 3.1RC1 https://www.eclipse.org/forums/index.php/m/1731699/#msg_1731699).
But when closing the whole Context by closing your web navigator none of the objects are destroyed.

I didn't find a proper walkthrough for the moment because I still have difficulty to understand how Eclipse e4 works in term of application life cycle. And what kind of methods to inject for controlling the closing of the UISession.
I have been able to register the method "beforeDestroy()" and close all my objects one by one by setting them to a null or almost empty object.

public static void registerClosingUIsession(EPartService partService, EModelService modelService,Shell shell){
	RWT.getUISession().addUISessionListener( new UISessionListener() {
		public void beforeDestroy( UISessionEvent event ) {
			for(MPart part : partService.getParts()){
                                 **** Destroy objects of each MPart ****
                                 arrayExample = new double[0][0]
                        }
                }
        }
}


At first I wanted to use beforeDestroy() to run :
partService.hidePart(part,true)
to trigger the proper closing of each MPart, but it didn't work, it just hide the Part.

The best would be to trigger previous to beforeDestroy() the closing of each MPart with the same way as their are closed when one click on the "close" button.

Re: memory leak in rap e4? [message #1741301 is a reply to message #1741260] Wed, 24 August 2016 09:14 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
I think the root cause is that we are not destroying the service context
upon shutdown.

The problem is that I'm currently so swapped with work that I can not
fix it in my free time! If you come up with a fix feel provide a
gerrit-review and I'll certainly merge it.

Tom

On 24.08.16 10:56, Christophe Becavin wrote:
> Hello,
> I am replying to this post because the problem is still there. I close
> my sessions but the model is still alive in the JVM along with the
> objects that were created inside MParts.
> https://www.eclipse.org/forums/index.php/t/262741/
Previous Topic:Duplicate Entry Point URL definition
Next Topic:Questions regarding context menus
Goto Forum:
  


Current Time: Thu Sep 19 16:24:45 GMT 2024

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

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

Back to the top