Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 321014

Summary: Leaking editors; CompatibilityPart.destroy() never called
Product: [Eclipse Project] e4 Reporter: Stefan Mücke <s.muecke>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: bokowski, remy.suen
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Profiler screenshot: GC roots for leaked editor
none
proposed patch none

Description Stefan Mücke CLA 2010-07-27 09:52:09 EDT
Created attachment 175313 [details]
Profiler screenshot: GC roots for leaked editor

1. Remember the heap size
2. Open 20 Java editors
3. Close the Java editors

Result: Memory leak of about 6 MB.

The cause is as follows:

In method CompatibilityPart.create(), two handlers are registered at the event broker; one of them is the 'objectSetHandler'. This handler will get wrapped in a UIEventHandler and will get registered in the ServiceRegistry.

Now, when a part is closed, this listener will be notified. Then, somewhat later, method destroy() should be called and the listeners would be unregistered. However, this does not happen.

I don't know when methods with @PreDestry are meant to be destroyed. However, the problem can be fixed by moving the eventBroker.unsubscribe(...) invocations to another place (see patch).
Comment 1 Stefan Mücke CLA 2010-07-27 09:53:49 EDT
Created attachment 175315 [details]
proposed patch

This patch fixes the largest part of the leak, but there still remains some smaller leak. I will investigate...
Comment 2 Remy Suen CLA 2010-07-27 10:00:00 EDT
How are you closing these editors? I used the 'X' in the tab and Ctrl+W, in both cases, my breakpoint in the @PreDestroy'd destroy() method is hit.
Comment 3 Stefan Mücke CLA 2010-07-27 10:07:11 EDT
With the 'X' or with 'Close All' in the tab's context menu.

Now method destroy gets called. Don't know why...
Comment 4 Stefan Mücke CLA 2010-07-27 10:31:12 EDT
Marking as invalid (as long as I cannot reproduce again).