[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.technology.ercp] memory usage by eswt

Hello,

I wrote a simpe test programm to see how much memory will be freed after eSWT window is closed. And found out that the memory is not freed, actually memory consumption usually increases by 40 Kb after I exit eswt cycle and do display.dispose().

I created a Destroyer thread that kills an eswt window and disposes display. I guess after display.dispose() some memory should be freed up.

Can someone comment on this?

regards,
Sergey Mylnikov

Here is a snippet . It is called from main with:
new TestMemoryPPC().open();


import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell;

public class TestMemoryPPC{
	Shell shell;
	Display display;
	
	public TestMemoryPPC() {
		display = Display.getDefault();
		shell = new Shell(display, SWT.CLOSE);
		shell.setText("testing memory");
		shell.setLayout(new FillLayout(SWT.VERTICAL));
		new Destroyer();
	}

	void open() {
		shell.layout();
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		display.dispose();
		display = null;
	}
	
	class Destroyer extends Thread {
		public Destroyer() {
			start();
		}
		
		public void run() {
			try {
				synchronized (this) {
					wait(10000);
					display.syncExec(new Runnable() {
						public void run() {
//							shell.close();
							shell.dispose();
						}
					});
					for (int i = 0; i < 60; i++) {
					 wait(1000);
					//forcing garbage collection
		                        Runtime.getRuntime().gc();
					}
				}
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}