CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Memory Leak in JQPlot ?

by c.schwoerer » 29 Jan 2020 08:45

Hi all,
I need some support.

If I update the JQPlotdata propery in a timer, the used browser memory in the taskmanger increases until a crash.

Testcase:
You need just a region,plot and timer in the form.

Thank you!

Code: Select all
unit Unit1;

interface

uses
  Classes, SysUtils, IWAppForm, IWApplication, IWColor, IWTypes, IWCGJQControl,
  IWCGJQPlotCharts, IWCGJQPlot, Vcl.Controls, Vcl.Forms, IWVCLBaseContainer,
  IWContainer, IWHTMLContainer, IWHTML40Container, IWRegion, IWBaseComponent,
  IWBaseHTMLComponent, IWBaseHTML40Component, IWCompExtCtrls;

type
  TIWForm1 = class(TIWAppForm)
    IWRegion1: TIWRegion;
    IWCGJQPlot1: TIWCGJQPlot;
    IWTimer1: TIWTimer;
    procedure IWAppFormCreate(Sender: TObject);
    procedure IWTimer1AsyncTimer(Sender: TObject; EventParams: TStringList);
  public
  end;

implementation

{$R *.dfm}
Uses IWCGAsyncRender,IWCGJQCommon;

procedure TIWForm1.IWAppFormCreate(Sender: TObject);
var
  AxisItem: TIWCGJQPlotOptionsAxesItem;
begin

  IWCGJQPlot1.JQPlotOptions.Title.Text:= 'MEM LEAK';

  AxisItem:= IWCGJQPlot1.JQPlotOptions.Axes.Add;
  AxisItem.Options.AxesRender:= jqparDateAxisRenderer;
  //AxisItem.Options.TickAxisOptions.FormatString:= '%d.&nbsp;%#b.<br>%R';


  AxisItem:= IWCGJQPlot1.JQPlotOptions.Axes.Add;
  AxisItem.AxisType:= jqpoxyYAxis;


end;

procedure TIWForm1.IWTimer1AsyncTimer(Sender: TObject;
  EventParams: TStringList);
begin
  IWCGJQPlot1.JQPlotData:='[[["10-10-20",12.3],["11-10-20",14.3]]]';

  RenderRegionAsync(IWRegion1,rramOldMethod,false);

end;

initialization
  TIWForm1.SetAsMainForm;
end.
c.schwoerer
 
Posts: 18
Joined: 25 Jan 2018 11:09

by c.schwoerer » 29 Jan 2020 14:31

Hi again,
you can check this issue in your own online demo too.

Open the demo with the Plot component.
Open your taskmanager.
Click many times on the left panellist and you will see with each click the used memory increases.

Tested with Firefox and Edge.

Thanks for your help.
c.schwoerer
 
Posts: 18
Joined: 25 Jan 2018 11:09

by c.schwoerer » 06 Feb 2020 18:10

No response?
c.schwoerer
 
Posts: 18
Joined: 25 Jan 2018 11:09

by XenoG » 29 Apr 2020 13:20

Did you find a way around this? I'm suffering a similar problem with JQPlot on Apple devices. It might be the browser is crashing due to memory leakage.

There's an interesting workaround here, https://www.cupidcontrols.com/2017/01/m ... th-jqplot/, but I'm not sure how we could incorporate this into our Delphi/C++ code.

Richard
XenoG
 
Posts: 34
Joined: 15 Nov 2016 15:04

by c.schwoerer » 24 Sep 2020 07:10

Hi,
in the meantime,I updated to Delphi10.4 with IW15.2.15 and cgdev V4.1.0.258
Who know's, but is seems the problem is gone.
MM4 reports also no longer leaks.

I don't know what these workaround means. I never use global vars. Even in IW projects.
I create the frames with plot components once and load each plot data from a database (and form it to a Json string).

regards.
c.schwoerer
 
Posts: 18
Joined: 25 Jan 2018 11:09

by XenoG » 24 Sep 2020 10:54

Hi c.schwoerer,

Many thanks for the update. I'm on Delphi 10.3, IW 15.0.17 and CGDev 4.1.0.159. I'm hoping that it's not the Delphi upgrade that's needed, as that will cost too much. Hopefully the fix is in IW or CGDev.

I'm not sure if it's related, but when I update charts (and other CGDev components) using AjaxReRender, you can get the same <script> injected into the HTML multiple times. I wonder if some devices don't like this and leak memory. One of the ways I found to combat this is to occasionally call RenderRegionAsync(parentRegion, true /*AClearRegionParent */, true /*resize*/, rramDefaultMethod); This clears down all the excess scripts, but is an ugly solution.

Thanks again for the information.

Richard
XenoG
 
Posts: 34
Joined: 15 Nov 2016 15:04

by c.schwoerer » 25 Sep 2020 08:51

Hi Richard,
I used Delphi 10.3, IW 15.0.17 and CGDev 4.1.0.159. before too. :(
May its a Atozed issue?
c.schwoerer
 
Posts: 18
Joined: 25 Jan 2018 11:09


Return to JQPlot

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.