Page 1 of 1

Memory leaks

Posted: Mon Dec 10, 2012 10:53 am
by 17463568
Hi,
I prepared an example with my problem:

Code: Select all


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 TestTChart {

	protected Shell shell;

	public static void main(String[] args) {
		try {
			TestTChart window = new TestTChart();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void open() {
		Display display = new Display();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	protected void createContents() {
		shell = new Shell();
		shell.setSize(450, 300);
		shell.setText("SWT Application");

		Button btnNewWindow = new Button(shell, SWT.NONE);
		btnNewWindow.setBounds(85, 134, 68, 23);
		btnNewWindow.setText("New window");
		btnNewWindow.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				new AnotherTestTChart().open();
			}
		});
	}
}

Code: Select all

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

import com.steema.teechart.TChart;

public class AnotherTestTChart {

	protected Shell shell;

	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	protected void createContents() {
		shell = new Shell();
		shell.setSize(450, 300);
		shell.setText("SWT Application");
		shell.setLayout(new FillLayout());

		new TChart(shell, SWT.NONE);
	}
}
In this example, I create one chart. After closing a window with a chart in memory stay 3 links on this chart and GC can not release resources. How can I solve this problem?

Re: Memory leaks

Posted: Mon Dec 10, 2012 2:56 pm
by yeray
Hi mora,
mora wrote:In this example, I create one chart. After closing a window with a chart in memory stay 3 links on this chart and GC can not release resources. How can I solve this problem?
Could you please explain how are you detecting it? We should reproduce it so we can try to find a solution.

Re: Memory leaks

Posted: Tue Dec 11, 2012 7:20 am
by 17463568
I'm using a VisualVM 1.3.5 for profiling. Take a look at the following pictures:
1. Before opening the window with a chart
2. A chart is created (and five links on it)
3. The window is closed and GC is called

Re: Memory leaks

Posted: Thu Dec 13, 2012 8:19 am
by yeray
Hi mora,

This is just to let you know we haven't forgotten this.
We'll be back to you here as soon as we'll get some conclusions.

Re: Memory leaks

Posted: Fri Jan 04, 2013 8:21 am
by 17463568
Hello Yearay

there are now some weeks over since I got last feedback.
Our project with external developers is now stopped because we can not use the software in this way.
Our project is a permanent visualization of thickness measurements of films and should run stable for weeks and months. Break of the software will lead to a break of production.

Re: Memory leaks

Posted: Fri Jan 04, 2013 10:51 am
by yeray
Hello mora,

I'd like to apologize for the delay here and the inconvenience generated.
The good news are that we've found what seems to be the cause of the problem. We are currently investigating the best way to fix it.
I hope we can send you a test version in the next days.

Re: Memory leaks

Posted: Fri Jan 04, 2013 1:22 pm
by yeray
Hi again Hubert,

I'm glad to tell you we've been able to fix the issue.
I'll send the modified unit (TChart.java) to the mail account you have registered in this forum.

Re: Memory leaks

Posted: Mon Jan 07, 2013 8:48 am
by 17463568
Hi Yeray

thx so lot. I've tested the new TChart and seems to work fine. But as I could see there are other changes since the last version we have.
Is it possible to get a new build of the Java version of Thchart, means new jars?

Regards
Hubert

Re: Memory leaks

Posted: Mon Jan 07, 2013 12:42 pm
by yeray
Hi Hubert,

I hope we can publish a new maintenance release soon.

Re: Memory leaks

Posted: Mon Jan 07, 2013 1:06 pm
by 17463568
:D
Yeray wrote:Hi again Hubert,

I'm glad to tell you we've been able to fix the issue.
I'll send the modified unit (TChart.java) to the mail account you have registered in this forum.

Re: Memory leaks

Posted: Mon Jan 21, 2013 9:54 am
by 17463568
Hi Yeray

have you any plan when the new release will be published?

Re: Memory leaks

Posted: Tue Jan 22, 2013 11:52 am
by yeray
Hi mora,
mora wrote:have you any plan when the new release will be published?
I hope we can publish a new maintenance release soon but I'm afraid I can't tell you a date for it.

Doesn't the corrected TChart.java allow you to get a working environment for you?

Re: Memory leaks

Posted: Wed Jan 23, 2013 6:34 am
by 17463568
Hi Yeray
thx for your answer. I'm awaiting the new release.
Because we have only one global class for charts, derived from TChart, and took the new TChart class into our project, it's quite feasible to work a short time without a complete new jar. But it would be better (for further updates) to have it full integrated into the oficial jar.

Hubert

Re: Memory leaks

Posted: Sun Mar 10, 2013 7:30 pm
by 17463568
Hi Yeray,

unfortunately, there's more leaks in Java version of TChart. It's still reproducible with the simple example above.
You can add the GDI Objects column to Task Manager to watch GDI object usage. I prefer to use free GDIView (to get a little bit more information).
After we close a window with a TChart instance, in the memory stay unreleased GDI-Objects. In VisualVM we can observ a lot of classes from the teechart package (Colors, Cursors, Rectangles, etc).

Re: Memory leaks

Posted: Tue Mar 12, 2013 8:36 am
by yeray
Hello mora,

I'll investigate it and answer you here:
http://www.teechart.net/support/viewtop ... ead#unread