Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 938

Summary: Memory leak at RemoveSeries
Product: VCL TeeChart Reporter: yeray alonso <yeray>
Component: SeriesAssignee: Steema Issue Manager <issuemanager>
Status: RESOLVED NOTABUG    
Severity: enhancement CC: david
Priority: ---    
Version: 140923   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
URL: http://www.teechart.net/support/viewtopic.php?f=1&t=15206
Chart Series: --- Delphi / C++ Builder RAD IDE Version:

Description yeray alonso 2014-10-01 10:47:04 EDT
RemoveSeries does not release the memory allocated to the removed series. 
If you open up TaskManager you'll see the memory allocated increases and never decreases:

uses Chart, Series;

var Chart1: TChart;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;
  Chart1.Align:=alClient;

  with TTimer.Create(Self) do
  begin
    Interval:=100;
    OnTimer:=Timer1Timer;
    Enabled:=true;
  end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  while Chart1.SeriesCount > 0 do
    Chart1.RemoveSeries(0);

  Chart1.AddSeries(TBarSeries).FillSampleValues();
end;
Comment 1 david berneda 2014-10-09 12:17:34 EDT
RemoveSeries simply removes the series from the chart.
It is equivalent to:

Chart1[0].ParentChart := nil;

or:

Series1.ParentChart := nil;

To destroy the series, do:

Series1.Free;

or:

Chart1[0].Free;

or, for all series in a chart:

Chart1.FreeAllSeries;