Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Memory leak with EditingDomainActionBarContributor?
Memory leak with EditingDomainActionBarContributor? [message #1741191] Tue, 23 August 2016 15:34 Go to next message
Michael Longo is currently offline Michael LongoFriend
Messages: 8
Registered: July 2015
Junior Member
Hello,

I have an issue with one of my custom EMF editor. When I close the editor, it is not fully garbage collected.

My issue is that the editor itself is scattered into multiple pieces so I can't really remove all the references pointed by the editor itself, so I wanted to free the editor itself (which sound logic to me).

However, it is not freed, and when I take a look with memory analyzer and look at the path to the root, it is kept by its action bar contributor (EditingDomainActionBarContributor) via the attribute "activeEditor" (see screenshot).

When I dispose the editor, I call setActiveEditor(null), but it doesn't reset the attribute.

So my question: is it a normal behavior from EditingDomainActionBarContributor? Or am I missing something so obvious?

Thanks.
Michael.
Re: Memory leak with EditingDomainActionBarContributor? [message #1741199 is a reply to message #1741191] Tue, 23 August 2016 16:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31961
Registered: July 2009
Senior Member
The generated editor has this in the

  public void dispose()
  {
    updateProblemIndication = false;

    ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);

    getSite().getPage().removePartListener(partListener);

    adapterFactory.dispose();

    if (getActionBarContributor().getActiveEditor() == this)
    {
      getActionBarContributor().setActiveEditor(null);
    }

    for (PropertySheetPage propertySheetPage : propertySheetPages)
    {
      propertySheetPage.dispose();
    }

    if (contentOutlinePage != null)
    {
      contentOutlinePage.dispose();
    }

    super.dispose();
  }


I'm not sure


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Memory leak with EditingDomainActionBarContributor? [message #1741210 is a reply to message #1741199] Tue, 23 August 2016 16:46 Go to previous messageGo to next message
Michael Longo is currently offline Michael LongoFriend
Messages: 8
Registered: July 2015
Junior Member
Yes I've seen ; I looked it up and I've mostly the same.

The part that interest me there, is there setActiveEditor(null), which I also call.

But if you look at the code (http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.5.2/org.eclipse.emf.edit/ui/2.5.0/org/eclipse/emf/edit/ui/action/EditingDomainActionBarContributor.java#EditingDomainActionBarContributor.setActiveEditor%28org.eclipse.ui.IEditorPart%29) the attribute 'activeEditor' is not set to null because it is not an instance of IEditingDomainProvider
Re: Memory leak with EditingDomainActionBarContributor? [message #1741245 is a reply to message #1741210] Wed, 24 August 2016 06:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31961
Registered: July 2009
Senior Member
That seems like a problem. Please open a Bugzilla. Of course you can specialize the class to work around it and of course this only leaks the most recent editor, i.e., at most one editor.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Memory leak with EditingDomainActionBarContributor? [message #1741270 is a reply to message #1741245] Wed, 24 August 2016 09:41 Go to previous messageGo to next message
Michael Longo is currently offline Michael LongoFriend
Messages: 8
Registered: July 2015
Junior Member
I'm sorry, I think at the end it is not a bug.

I've looked at existing issues, and further into the code, and I think my issue was at a higher level. The issue was not that the ActionBarContributor didn't release the editor, but the fact that the ToolbarManager didn't release the ActionBarContributor.

I think I found my issue, it was that I removed some contributions from the toolbar manager before disposing the toolbar manager, so the removed contribution were not disposed and so the ToolbarManager still kept a reference to them, or something like that.

But it might still be a good idea to "fix" the activeEditor-thing to add more security...

Re: Memory leak with EditingDomainActionBarContributor? [message #1741438 is a reply to message #1741270] Thu, 25 August 2016 06:53 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 31961
Registered: July 2009
Senior Member
The ActionBarContributor is shared across editors and one would expect it would be disposed after the last editor that needs it is closed. But as you say, it still seems wrong that it should hold onto an old active editor until there is a non-null new one set. Please do open a Bugzilla with a reference to this thread.

Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Efficient check on EDataType
Next Topic:[Xcore/2] circular dependencies
Goto Forum:
  


Current Time: Mon Aug 02 18:45:51 GMT 2021

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

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

Back to the top