memory leak on iOS with teechart (FMX, C++)

TeeChart FireMonkey (Windows,OSX,iOS & Android) for Embarcadero RAD Studio, Delphi and C++ Builder (XE5+)
Post Reply
relayman
Newbie
Newbie
Posts: 20
Joined: Tue Jun 25, 2019 12:00 am

memory leak on iOS with teechart (FMX, C++)

Post by relayman » Wed Sep 04, 2019 1:58 am

I'm experiencing crashes of my app with Xcode Console reporting as EXC_RESOURCE -> myappname[5548] exceeded mem limit: ActiveHard 1400MB (fatal). I created a simple project to reproduce the error and it crashes too (attached code). Below are snips from the Xcode Console output. I get tons of assertions, then the Received memory warning, then the iOS kernal kills my app (Project1).

default 20:28:26.180333 -0500 assertiond [Project1:7693] Activate assertion: <BKProcessAssertion: 0x12b0102c0; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:…8EA7F5E94DD5>
default 20:28:26.180542 -0500 assertiond [Project1:7693] Setting jetsam priority to 10 [0x10108]
default 20:28:26.182151 -0500 assertiond [Project1:7693] Deactivate assertion: <BKProcessAssertion: 0x12b0102c0; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:…8EA7F5E94DD5>
default 20:28:26.182312 -0500 assertiond [Project1:7693] Setting jetsam priority to 10 [0x10100]
default 20:28:26.183307 -0500 assertiond [Project1:7693] Remove assertion: <BKProcessAssertion: 0x12b0102c0; "com.apple.UIKit.KeyboardManagement.message" (finishTask:180s); id:…8EA7F5E94DD5>
default 20:28:32.609723 -0500 Project1 Received memory warning.


Then a short time later the app crashes and i see the following console message:

default 20:28:45.881914 -0500 kernel EXC_RESOURCE -> Project1[7693] exceeded mem limit: ActiveHard 1400 MB (fatal).

My crash test app is a simple Firemonkey app built in C++ Builder 10.3.2 (attached).

A) Put a TPanel on the form (Panel1).
B) Put a TScrollBox on Panel1 (ScrollBox1). Set its align to Contents.
C) Put a TLayout on ScrollBox1 (Layout1). Set its align to None. Set its width to 2100.
D) Put a TChart on Layout1. Set its height to 200, width 7300. Set its align to None.
E) Add a TToolBar to Form1 and put a TButton on it.
F) Then put this code in the TButton's click event:

Code: Select all

 Form1->Layout1->Position->X = 0;
 Form1->ChartTest->Position->Y = 0;
 Form1->ChartTest->Position->X = 0;

 TLineSeries *series1 = new TLineSeries(Form1);
 TLineSeries *series2 = new TLineSeries(Form1);
 TLineSeries *series3 = new TLineSeries(Form1);
 TLineSeries *series4 = new TLineSeries(Form1);

 series1->Color = claBlue;   //https://qiita.com/7of9/items/987a519f7e4679440230
 series2->Color = claRed;
 series3->Color = claBlueviolet;
 series4->Color = claAqua;

	  double x, y;
	  for (int i = 0; i < 1000; i++) {

	   x = i;
	   y = Random(5000);
	   series1->AddXY(x,y);
	   y = Random(5000);
	   series2->AddXY(x,y);
	   y = Random(5000);
	   series3->AddXY(x,y);
	   y = Random(5000);
	   series4->AddXY(x,y);
	  }

 Form1->ChartTest->AddSeries(series1);
 Form1->ChartTest->AddSeries(series2);
 Form1->ChartTest->AddSeries(series3);
 Form1->ChartTest->AddSeries(series4);
G) And now, with your iOS device connected to your mac and Xcode Console open, filter the Console output on "Project1" if that is what you named it (default). Then run the app and scroll backwards/forwards and/or up/down (also change orientation if you want back and forth). You will see tons of assertions. Eventually (takes around 2-3 minutes of this harassment to make it crash) it will eat up enough memory that it crashes.

The memory leak is in the TeeChart most likely, maybe in the TScrollBox? I've zipped up the entire directory of my test project and attached it.

thanks,
russ
Attachments
Project1.zip
(14.61 KiB) Downloaded 1783 times

relayman
Newbie
Newbie
Posts: 20
Joined: Tue Jun 25, 2019 12:00 am

Re: memory leak on iOS with teechart (FMX, C++)

Post by relayman » Wed Sep 04, 2019 11:50 pm

I've tested and the memory leak is not in ScrollBox, it is in the TChart. In the attached project (zip) i simply added a timer that moves the TChart up and down every 0.1 seconds. After 2-3 minutes it crashes on memory error on iOS with no user input after clicking Button1. On Win32 memory is stable and not growing.

So, i'm hoping there is something obvious in how i create the chart that is the deficiency - i really don't want to abandon ship as Steema charts are so flexible. Any ideas?

thanks,
russ

p.s. I'm using TeeChartVCLFMXStandard-2019.27 and i'm building in C++Builder in Rad Studio (10.3.2 - Version 26.0.34749.6593).
Project1a.zip
Simple example that shows the bug on iOS.
(14.81 KiB) Downloaded 1709 times

relayman
Newbie
Newbie
Posts: 20
Joined: Tue Jun 25, 2019 12:00 am

Re: memory leak on iOS with teechart (FMX, C++)

Post by relayman » Thu Sep 05, 2019 2:08 am

Ok, this looks like a memory leak bug introduced sometime AFTER TeeChart Standard version v2016.17.160129. This is the lite version that comes free with Rad Studio 10.3.2.

I uninstalled my licensed copy of TeeChart Standard VCL/FMX released May 30, 2019 - Build 2019.27.190530. Then, uninstalled/reinstalled Rad Studio to include the free (lite) version of TeeChart (v2016.17.160129). This solved the memory leak issue so I'm pretty confident the leak was introduced in a later build of TeeChart Standard.

thanks,
russ

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

Re: memory leak on iOS with teechart (FMX, C++)

Post by Yeray » Fri Sep 06, 2019 11:10 am

Hello,

I'm finding problems to trace this memory leak in iOS but it seems it can be also reproducible in Android.
I can see the memory allocations gradually increasing using Android Studio Profiler.
However, if I remove the TScrollBox and the TLayout I place the TChart directly on the TForm, the memory allocations still increase, but at a lower speed.
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

relayman
Newbie
Newbie
Posts: 20
Joined: Tue Jun 25, 2019 12:00 am

Re: memory leak on iOS with teechart (FMX, C++)

Post by relayman » Fri Sep 06, 2019 1:48 pm

Hi Yeray - thank you for looking into it. Can you try building and testing with v2016.17.160129 to see if it runs without memory leak?

best regards,
russ

relayman
Newbie
Newbie
Posts: 20
Joined: Tue Jun 25, 2019 12:00 am

Re: memory leak on iOS with teechart (FMX, C++)

Post by relayman » Fri Sep 20, 2019 2:58 pm

Hi Yeray,

Did you have a chance to try building and testing with v2016.17.160129 to see if it runs without memory leak?

thank you,
russ

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

Re: memory leak on iOS with teechart (FMX, C++)

Post by Yeray » Tue Sep 24, 2019 6:37 am

Hello,

I have been able to reproduce the memory leak in Android with TeeChart v2017.22 and Tokyo.
And, as you indicated, the memory leak is not present using TeeChart v2016.17 Lite shipped with Rio.

I've found the memory leak appeared in v2017.22. So the last version without this memory leak is v2017.21.
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: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: memory leak on iOS with teechart (FMX, C++)

Post by Yeray » Tue Sep 24, 2019 8:53 am

Hello,

It seems the memory leak was introduced when implementing the fix for #1830.
We are storing the labels bounds when drawing them and this seems to be causing a memory leak in Android and iOS.

I've added a new bug ticket to address this bug here:
http://bugs.teechart.net/show_bug.cgi?id=2243
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

relayman
Newbie
Newbie
Posts: 20
Joined: Tue Jun 25, 2019 12:00 am

Re: memory leak on iOS with teechart (FMX, C++)

Post by relayman » Fri Oct 11, 2019 3:07 pm

Hi Yeray,

I just now purchased the Pro version so i can create polar plots. I downloaded that older version (v2017.21) to avoid this memory leak. When i install i get an error message, "TeeChart files to AUTO install cannot be found." I click OK and it finishes, but i don't get the Pro features in Rad Studio, just the lite.

I’m working in Rad Studio Rio (10.3) but the installer only goes up to Tokyo. What do i need to do to get that older version to work with Rio 10.3?

thanks,
russ

p.s. I'm using C++, don't care about Delphi.

relayman
Newbie
Newbie
Posts: 20
Joined: Tue Jun 25, 2019 12:00 am

Re: memory leak on iOS with teechart (FMX, C++)

Post by relayman » Fri Oct 11, 2019 5:17 pm

By modifying the "19.0" key as here: https://www.steema.com/support/viewtopi ... 6&start=15, i was able to run the installer without any errors. However, i still just have the "TeeChart Lite FMX Components", no Pro. So, looks like still need help installing this older Pro build for use with Rio.

thanks,
russ

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

Re: memory leak on iOS with teechart (FMX, C++)

Post by Yeray » Mon Oct 14, 2019 1:44 pm

Hello,

I'll send you a test version where we're not saving the labels bounds in Android&iOS, which was the fix for #1830.
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