Community
Participate
Working Groups
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
Created attachment 208544 [details] profiling result
Created attachment 208545 [details] quickfix I've patched IXtendXpandProject, XtendXpandProject & XtendXpandModelManager so that the IElementChangeListener is removed by XtendXpandModelManager.
Comment on attachment 208545 [details] quickfix a proper solution should just affect implementation of XtendXpandProject without changing interface IXtendXpandProject
Confirmed the profiling result
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.
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.
Requested via bug 522520. -M.