Bug 33927

Summary: Leak in Java Editor
Product: [Eclipse Project] JDT Reporter: Kevin Haaland <Kevin_Haaland>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: akiezun, n.a.edgar
Version: 2.1   
Target Milestone: 2.1 RC3   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Kevin Haaland CLA 2003-03-05 18:04:10 EST
In 03/04 build 

Import all projects as binary projects
Open Java Perspective
Expand org.eclipse.jdt.internal.corext
Edit Assert.java

Every time you open/close this file aprox 100k of java objects are leaked

I'll update this defect report as I find more information.
Comment 1 Kevin Haaland CLA 2003-03-05 18:04:16 EST
Added Nick as the leak may also be in the platform-ui code.

Small correction to the steps:
   binary projects for org.apache.*
   source projects for the rest
Comment 2 Dirk Baeumer CLA 2003-03-06 03:50:30 EST
*** Bug 33922 has been marked as a duplicate of this bug. ***
Comment 3 Dirk Baeumer CLA 2003-03-06 03:50:54 EST
Adam, can you try to reproduce this
Comment 4 Kevin Haaland CLA 2003-03-10 10:19:08 EST
Kai,Adam

 The Platform UI team has fixed a leak in IActionDelegate2. See this defect for 
details:

 http://bugs.eclipse.org/bugs/show_bug.cgi?id=34010
Comment 5 Adam Kiezun CLA 2003-03-11 05:56:52 EST
JavaModelOperation has a static reference to PerThreadObject
and stores there every reconcile thread that ever existed, even after its death
reconcile threads have references to CompilationUnitEditors and from there 
everything is leaked

maybe jcore should remove reconcile threads from the map as soon as they die
asking jcore for comment
Comment 6 Adam Kiezun CLA 2003-03-11 06:32:16 EST
this is a source of leaks in other places as well - it stores all 
ModelContextThreads too
Comment 7 Jerome Lanneluc CLA 2003-03-11 06:54:51 EST
Thanks for investigating Adam.

When poping the last operation (i.e. the top level operation), we should remove 
the reference to the current thread.

Proposed fix on JavaModelOperation:
	/*
	 * Removes the last pushed operation from the stack of running 
operations.
	 * Returns the poped operation or null if the stack was empty.
	 */
	protected JavaModelOperation popOperation() {
		ArrayList stack = getCurrentOperationStack();
		int size = stack.size();
		if (size > 0) {
			if (size == 1) { // top level operation -> free memory 
(see http://bugs.eclipse.org/bugs/show_bug.cgi?id=33927)
				operationStacks.setCurrent(null);
			}
			return (JavaModelOperation)stack.remove(size-1);
		} else {
			return null;
		}
	}
Comment 8 Philipe Mulet CLA 2003-03-11 16:54:33 EST
Approved change suggestion. 
Integrated for RC3.
Comment 9 David Audel CLA 2003-03-20 08:16:25 EST
Verified.