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

Bug 419771

Summary: Dozens of zombie threads are created with JFace Dialog on OS X when using Oracle JVM
Product: [Eclipse Project] Platform Reporter: Mark McLaren <mark.k.mclaren>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: lshanmug, pwebster
Version: 4.3.1Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard: stalebug

Description Mark McLaren CLA 2013-10-17 18:22:53 EDT
A typical Jface application can create dozens or hundereds of 'zombie' threads which are never destroyed.

Tested on: OS X 10.8.4, Jface/SWT version 4.3.1, Oracle JDK 7 Update 45.

To reproduce: 
1. Run the snippet below using a debugger 
2. Click the 'Open Dialog' button. In the debugger, notice that a new Daemon Thread called Thread-1 has been created.
3. Close the dialog and click 'Open Dialog' again.  A new Daemon Thread called Thread-2 is created.
4. Open another OS X application (eg. Calculator) so that the Jface dialog is no longer the active window.
5. Click on the Jface dialog to make it active again - a new Daemon Thread called Thread-3 is created.

Note that this problem only appears when running the Oracle JVM.  The Apple JVM doesn't create these extra threads.


Snippet:
--------------------------
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TestShellOpen {

	public static void main(String[] args) {


		Display display = new Display();
		final Shell shell = new Shell(display);
		Button btn = new Button(shell, SWT.PUSH);
		btn.setText("Open Dialog");
		btn.setBounds(25, 20, 150, 30);
		btn.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				 Dialog dialog = new Dialog(shell){};
				 dialog.open();
			}
		});
		
		shell.setSize(200, 200);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Comment 1 Lakshmi P Shanmugam CLA 2017-07-03 07:46:41 EDT
Bug triaged, visit https://wiki.eclipse.org/SWT/Devel/Triage for more
information.
Comment 2 Eclipse Genie CLA 2019-11-20 09:02:15 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.