Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 367065 - Memory Leak caused by adding IElementChangedListener, added in ctor of XtendXpandProject, which is never be released when a project is deleted
Summary: Memory Leak caused by adding IElementChangedListener, added in ctor of XtendX...
Status: CLOSED FIXED
Alias: None
Product: M2T
Classification: Modeling
Component: Xpand (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: SR1   Edit
Assignee: Karsten Thoms CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-19 07:24 EST by Johannes Dicks CLA
Modified: 2017-10-31 11:24 EDT (History)
2 users (show)

See Also:
karsten.thoms: iplog-
karsten.thoms: juno+


Attachments
profiling result (137.81 KB, image/png)
2011-12-19 07:30 EST, Johannes Dicks CLA
no flags Details
quickfix (7.02 KB, application/zip)
2011-12-19 07:48 EST, Johannes Dicks CLA
karsten.thoms: iplog+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Dicks CLA 2011-12-19 07:24:17 EST
Build Identifier: 1.2.0.v201111160409

After importing and deleting xpand projects several times, it was observed that some memory will never be released.

This is caused because an IElementChangedListener is registered to the JavaCore, within ctor of XtendXpandProject, which will never been deleted if a project is deleted. The IElementChangedListener keeps XtendXpandProject reference away from GC.

Reproducible: Always

Steps to Reproduce:
1. import & delete a project several times
2. use a profiler to find remaining references to XtendXpandProject after deletion of all projects out of the workspace
Comment 1 Johannes Dicks CLA 2011-12-19 07:30:36 EST
Created attachment 208544 [details]
profiling result
Comment 2 Johannes Dicks CLA 2011-12-19 07:48:11 EST
Created attachment 208545 [details]
quickfix

I've patched IXtendXpandProject, XtendXpandProject & XtendXpandModelManager so that the IElementChangeListener is removed by XtendXpandModelManager.
Comment 3 Johannes Dicks CLA 2011-12-19 08:43:39 EST
Comment on attachment 208545 [details]
quickfix

a proper solution should just affect implementation of XtendXpandProject without changing interface IXtendXpandProject
Comment 4 Karsten Thoms CLA 2012-07-12 10:37:38 EDT
Confirmed the profiling result
Comment 5 Karsten Thoms CLA 2012-07-12 11:53:45 EDT
Proposed patch must be modified: For backward compatibility it is not possible to introduce the interface method on IXtendXpandProject. Rather an extended interface IXtendXpandProject2 must be created.

Due to different formatting it is hard to see the actual changes :( Next time please avoid formatting of the code.
Comment 6 Karsten Thoms CLA 2012-08-13 16:30:33 EDT
The issue is solved now without need to extend the IXtendXpandProject interface:

XtendXpandProject registers an IResourceChangeListener, which deregisters the IElementChangeListener and itself when the project is removed from the workspace. When this happens it is important that the XtendXpandProjects frees all its contained resources, otherwise the project is referenced again by an element in the 'resources' map.

Further XtendXpandBuilder did not free the project, since it is indirectly referenced by the 'toAnalyze' set.

Now the project can be GCed when it is removed from the workspace.
Comment 7 Eclipse Webmaster CLA 2017-10-31 11:24:40 EDT
Requested via bug 522520.

-M.