Free CustomAxes?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Softdrill NL
Newbie
Newbie
Posts: 14
Joined: Thu Dec 28, 2017 12:00 am

Free CustomAxes?

Post by Softdrill NL » Sun Apr 06, 2025 8:52 am

Hi,

I create a certain amount of CustomAxes in my TChart, e.g. by using:

Code: Select all

LAxis := TChartAxis.Create(MyChart)
However, it's not clear to me whether I need to destroy (Free) these axes myself or is the parent chart (MyChart) taking care of this?

In my Project Source I have

Code: Select all

ReportMemoryLeaksOnShutdown := true
If I don't explicitely destroy the CustomAxes, no leaks are reported. However, I cannot find anything in the documentation. Can you please advise on the correct approach to remove (destroy) all CustomAxes? Is there something like:

Code: Select all

MyChart.FreeAllCustomAxes
or should it be

Code: Select all

for ii := 0 to MyChart.CustomAxes.Count - 1 do
MyChart.CustomAxes[ii].Free;
Thanks,
Mark

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

Re: Free CustomAxes?

Post by Yeray » Mon Apr 07, 2025 6:21 am

Hello Mark,

CustomAxes is a public property in the TCustomAxisPanel (and derived such as TChart) to access the private FCustomAxes : TChartCustomAxes property (TChartCustomAxes, inherits TOwnedCollection).
Indeed, at the TCustomAxisPanel.Destroy destructor method, the CustomAxes are freed:

Code: Select all

Destructor TCustomAxisPanel.Destroy;
Begin
//...
  FCustomAxes.Free;
//...
end;
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

Softdrill NL
Newbie
Newbie
Posts: 14
Joined: Thu Dec 28, 2017 12:00 am

Re: Free CustomAxes?

Post by Softdrill NL » Mon Apr 07, 2025 6:45 am

Clear, thank you! It's a bit counter-intuitive (typically manual creation requires manual destruction in Delphi) so perhaps an idea to add this to the documentation? :D

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

Re: Free CustomAxes?

Post by Yeray » Mon Apr 07, 2025 8:53 am

Hello,

Note the CustomAxes (and many other objects) can also be created at design time or at runtime via the editor. So I guess that would be an obstacle to that "manual creation requires manual destruction" rule.
But yes, I'll check if we can add a note somewhere in the docs.
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