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

Bug 319424

Summary: Memory leaks with perspective switching (related to XMLModelReconciler)
Product: [Eclipse Project] e4 Reporter: Stefan Mücke <s.muecke>
Component: UIAssignee: Project Inbox <e4.ui-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bokowski, remy.suen
Version: unspecified   
Target Milestone: 1.0 RC2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Profiler screenshot: Memory retained by XMLModelReconciler (before/after)
none
Profiler screenshot: Allocation stack trace for PerspectiveSwitcher none

Description Stefan Mücke CLA 2010-07-09 14:37:34 EDT
Here's what I did:

1. Open a fresh e4 workbench
2. Open the Debug perspective
3. Take a memory snapshot
4. Switch between the Java and Debug perspectives 50 times
5. Take another memory snapshot
6. Compare the memory snapshots

Switching the perspectives 50 times increased the heap size by about 2 MB, which is a leak.

1 MB of this is retained by the XMLModelReconciler. The XMLModelReconciler uses a ChangeRecorder to keep track of changes in the model. This ChangeRecorder retains a great number of model objects; these model objects are rooted at the ChangeRecorder, which means that they are no longer alive.

Another (very small) leak is that after switching the perspectives (50+10 times), there were 62 PerspectiveSwitcher instances (originally there was only one). See screenshot for allocation stack trace.

There are some more leaks related to perspective switching (the other 1 MB of the above 2 MB). There are leaked TrackableComputationExt instances. These trackables use WeakReferences, so perhaps the leak will disappear when the other leaks are fixed.
Comment 1 Stefan Mücke CLA 2010-07-09 14:39:26 EDT
Created attachment 173892 [details]
Profiler screenshot: Memory retained by XMLModelReconciler (before/after)
Comment 2 Stefan Mücke CLA 2010-07-09 14:40:31 EDT
Created attachment 173894 [details]
Profiler screenshot: Allocation stack trace for PerspectiveSwitcher
Comment 3 Remy Suen CLA 2010-07-14 08:06:03 EDT
(In reply to comment #0)
> Another (very small) leak is that after switching the perspectives (50+10
> times), there were 62 PerspectiveSwitcher instances (originally there was only
> one). See screenshot for allocation stack trace.

I don't think this should be a problem anymore as Paul has fixed my trim code to not regenerate new instances.
Comment 4 Stefan Mücke CLA 2010-07-14 08:09:34 EDT
Okay, I will verify this.
Comment 5 Stefan Mücke CLA 2010-07-14 11:30:03 EDT
Verified in CVS Head. Marking as fixed.