Memory leaks

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
mora
Newbie
Newbie
Posts: 19
Joined: Thu Sep 27, 2012 12:00 am
Contact:

Memory leaks

Post by mora » Mon Dec 10, 2012 10:53 am

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?

Yeray
Site Admin
Site Admin
Posts: 9617
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Memory leaks

Post by Yeray » Mon Dec 10, 2012 2:56 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

mora
Newbie
Newbie
Posts: 19
Joined: Thu Sep 27, 2012 12:00 am
Contact:

Re: Memory leaks

Post by mora » Tue Dec 11, 2012 7:20 am

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
Attachments
1.png
Before opening the window with a chart
1.png (60.22 KiB) Viewed 34488 times
2.png
A chart is created (and five links on it)
2.png (73.64 KiB) Viewed 34500 times
3.png
The window is closed and GC is called
3.png (63.06 KiB) Viewed 34493 times

Yeray
Site Admin
Site Admin
Posts: 9617
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Memory leaks

Post by Yeray » Thu Dec 13, 2012 8:19 am

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

mora
Newbie
Newbie
Posts: 19
Joined: Thu Sep 27, 2012 12:00 am
Contact:

Re: Memory leaks

Post by mora » Fri Jan 04, 2013 8:21 am

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.

Yeray
Site Admin
Site Admin
Posts: 9617
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Memory leaks

Post by Yeray » Fri Jan 04, 2013 10:51 am

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9617
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Memory leaks

Post by Yeray » Fri Jan 04, 2013 1:22 pm

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

mora
Newbie
Newbie
Posts: 19
Joined: Thu Sep 27, 2012 12:00 am
Contact:

Re: Memory leaks

Post by mora » Mon Jan 07, 2013 8:48 am

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

Yeray
Site Admin
Site Admin
Posts: 9617
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Memory leaks

Post by Yeray » Mon Jan 07, 2013 12:42 pm

Hi Hubert,

I hope we can publish a new maintenance release soon.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

mora
Newbie
Newbie
Posts: 19
Joined: Thu Sep 27, 2012 12:00 am
Contact:

Re: Memory leaks

Post by mora » Mon Jan 07, 2013 1:06 pm

: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.

mora
Newbie
Newbie
Posts: 19
Joined: Thu Sep 27, 2012 12:00 am
Contact:

Re: Memory leaks

Post by mora » Mon Jan 21, 2013 9:54 am

Hi Yeray

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

Yeray
Site Admin
Site Admin
Posts: 9617
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Memory leaks

Post by Yeray » Tue Jan 22, 2013 11:52 am

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?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

mora
Newbie
Newbie
Posts: 19
Joined: Thu Sep 27, 2012 12:00 am
Contact:

Re: Memory leaks

Post by mora » Wed Jan 23, 2013 6:34 am

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

mora
Newbie
Newbie
Posts: 19
Joined: Thu Sep 27, 2012 12:00 am
Contact:

Re: Memory leaks

Post by mora » Sun Mar 10, 2013 7:30 pm

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).

Yeray
Site Admin
Site Admin
Posts: 9617
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Memory leaks

Post by Yeray » Tue Mar 12, 2013 8:36 am

Hello mora,

I'll investigate it and answer you here:
http://www.teechart.net/support/viewtop ... ead#unread
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply