Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360610 - TableColumn.pack() causes memory leak if Shell has style TOOL
Summary: TableColumn.pack() causes memory leak if Shell has style TOOL
Status: CLOSED DUPLICATE of bug 338975
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.2   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-12 01:43 EDT by Mark McLaren CLA
Modified: 2012-08-06 04:52 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark McLaren CLA 2011-10-12 01:43:18 EDT
Build Identifier: 3.7.1

On OS X 10.7.1, if TableColumn.pack() is called on a table which exists on a 'Tool' window then a memory leak occurs.  The size of the memory leak is proportional to the area of the window.


Reproducible: Always

Steps to Reproduce:
1. Run the OS X Activity Monitor
2. Run the code snippet below
3. Click anywhere in the SWT window - this will show a new Tool window
4. Close the Tool window
5. In the Activity Monitor note the Real Mem value for the SWT process
6. Repeat steps 3 and 4 ten times
7. Again note the Real Mem value for the SWT process - it is about 80mb larger than in step 5.  This indicates that the size of the memory leak is about 8mb each time the window is opened. 

Note that this problem only occurs if the Shell style includes TOOL and the method pack() is called on the TableColumn.

---------------- code snippet ------------------

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;

public class TestMemoryLeak {

	public static void main(String[] args) {
		Display display = new Display();
		final Shell shell = new Shell(display);

		shell.addMouseListener(new MouseAdapter() {
			Shell topShell = null;

			@Override
			public void mouseDown(MouseEvent e) {
				if (topShell != null) {
					topShell.dispose();
				}

				topShell = new Shell(shell, SWT.DIALOG_TRIM | SWT.TOOL);
				topShell.setSize(2000, 1000);
				topShell.open();
				topShell.setText("Tools");

				Table table = new Table(topShell, SWT.BORDER);
				table.setHeaderVisible(true);
				table.setBounds(20, 20, 100, 100);
				TableColumn col = new TableColumn(table, SWT.LEFT);
				col.setText("Tooly Dooly");
				col.setWidth(30);
				col.pack();

			}
		});
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Comment 1 Lakshmi P Shanmugam CLA 2012-08-06 04:52:12 EDT
This is same as Bug 338975, and has been fixed in 3.7.2 & 3.8.

*** This bug has been marked as a duplicate of bug 338975 ***