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

Bug 273910

Summary: [Shell] 'savedFocus' not handled correctly, leading to memory-leaks
Product: [RT] RAP Reporter: Stefan Hansel <stefan.hansel>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.2   
Target Milestone: 1.2 M7   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
reproduces the problem none

Description Stefan Hansel CLA 2009-04-27 12:56:07 EDT
Created attachment 133393 [details]
reproduces the problem

Shell.savedFocus is not handled correctly, in certain situations it will hold a reference to a disposed Control.

This in turn leads to memory-leaks, as the referenced Control.parent isn't nulled on disposal (which is a bug itself). In our scenario starting with the savedFocus over some parents a quite big disposed Composite cannot be garbage collected.

In our case we could live with a nulled parent, if that's easier to fix. Most of the memory in question could be reclaimed by the garbage collector.
Futhermore our HEAP-analyses for other memory-leaks would be far easier.

Attached you will find a small Tester to reproduce the problem.
The tester can be started as a SWT-app (via main) or RWT-app (as it is an IEntryPoint as well).

Do the following to reproduce:
1) start app (RWT or SWT), you will see a window with two tabs
2) click tab 2
3) close tab 2
4) create a HEAP-Dump

When closing the second tab, the second Text-field is disposed.
In SWT there is only 1 Text left on the heap.
In RWT there are two Text's on the heap.

The problem only turns up, when the second Text request the focus as done in the tester.
Comment 1 RĂ¼diger Herrmann CLA 2009-04-28 05:08:26 EDT
The savedFocus field is now nulled when it holds the control that is about to be disposed.
Changes are in CVS HEAD

Please file a separate bug report if you consider it a bug that Control#parent isn't nulled on dispoal,