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

Bug 357586

Summary: XmlEditorResourceStore memory leak / thread consumption
Product: z_Archived Reporter: Carlin Rogers <carlin.rogers>
Component: SapphireAssignee: Konstantin Komissarchik <konstantin>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: konstantin
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Carlin Rogers CLA 2011-09-14 01:15:03 EDT
Sapphire editors from an adopter product leave XmlEditorResourceStore.Scrubber threads that don't seem to terminate. Closing the SapphireEditor does not terminate the thread. Since the Scrubber thread doesn't terminate the and contains a reference to the XmlEditorResourceStore instance that created and started the thread. The XmlEditorResourceStore has references to the SapphireEditor and the root model and since the thread is not terminated and the reference to the XmlEditorResourceStore is maintained this causes memory leaks. Every time you open and close a file (even the same file) in the SapphireEditor, a new Scrubber thread is created, adding to the number of threads and memory consumed.

The workbench call dispose() on the SapphireEditor and in turn disposes the model which frees up some objects. I noticed in various that the dispose method does not set the model reference to null and the XmlEditorResourceStore also still has the reference to the model as well as the editor so these and other objects are never collected.

Using a memory analysis tool you can see the instances of each Scrubber thread, XmlEditorResourceStore, editor, model, etc that remain. 

Here's an example thread dump of a thread that remains after the editor has been closed.

"Thread-27" prio=6 tid=0x048d7400 nid=0x11e0 waiting on condition [0x0614f000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(Native Method)
	at org.eclipse.sapphire.ui.swt.xml.editor.XmlEditorResourceStore$Scrubber.run(XmlEditorResourceStore.java:479)
	- locked <0x0bce0000> (a org.eclipse.sapphire.ui.swt.xml.editor.XmlEditorResourceStore$Scrubber)
Comment 1 Konstantin Komissarchik CLA 2011-09-14 06:59:20 EDT
Fixed in 0.3.1 and 0.4 streams. Please verify.
Comment 2 Carlin Rogers CLA 2011-09-14 14:14:46 EDT
verified fixed in 0.3.1, testing with the adopter product.
Comment 3 Konstantin Komissarchik CLA 2011-09-14 14:21:08 EDT
Thanks. Closing.