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

Bug 170183

Summary: Leak caused by SaveablesList.removeModel
Product: [Eclipse Project] Platform Reporter: Dani Megert <daniel_megert>
Component: UIAssignee: Boris Bokowski <bokowski>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: Olivier_Thomann
Version: 3.3   
Target Milestone: 3.3 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Dani Megert CLA 2007-01-11 04:31:33 EST
I20070110-1800

1. open a text editor
2. close the text editor
==> editor instance still there (leaked)

Repeating step 1 and 2 leaks an additional editor each time.

REASON: the code in SaveablesList.removeModel is wrong (looks like copy/paste error of code copied from addModel):

	boolean result = false;
	Set modelsForSource = (Set) modelMap.get(source);
	if (modelsForSource == null) {
!BAD>		modelsForSource = new HashSet();       <-- BAD!
!BAD>		modelMap.put(source, modelsForSource); <-- BAD!
	}
	if (modelsForSource.remove(model)) {
		result = decrementRefCount(modelRefCounts, model);
		if (modelsForSource.isEmpty()) {
			modelMap.remove(source);
		}
	}
	return result;
Comment 1 Dani Megert CLA 2007-01-11 04:33:03 EST
The build id is I20070110-1600 and not I20070110-1800.
Comment 2 Dani Megert CLA 2007-01-11 04:49:04 EST
Boris, see bug 170184 for details why removeModel got called twice.

I committed a workaround in Platform Text that takes the current life-cycle as outlined in bug 170184 into account.
Comment 3 Boris Bokowski CLA 2007-01-11 15:33:05 EST
Fix released >20070111.