Forum > Packages and Libraries

TATTabs memory leak

(1/5) > >>

chrv:
Code below run fine. I can add several tabs at runtime.
Problem when checking for memory leak : 1 unfreed memory block by new tab created.
NB :
- no memory leak if no text is added to the tab
- same hapens with demo : ATFlatControls>app>demo_tabs

What Am i missing ?


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, attabs;type  TForm1 = class(TForm)    Button1: TButton;    Edit1: TEdit;    procedure Button1Click(Sender: TObject);    procedure FormCreate(Sender: TObject);  private  public    AT : TATTabs;  end;var  Form1: TForm1;implementation{$R *.lfm}procedure TForm1.FormCreate(Sender: TObject);begin  AT := TATTabs.Create(Form1);  AT.parent := self;  AT.Align:=alTop;end;procedure TForm1.Button1Click(Sender: TObject);var  aTab : TATTabData;begin  aTab := TATTabData.Create(AT.Tabs);  aTab.TabCaption:=Edit1.Text;end;           

Alextp:
aTab := TATTabData.Create(AT.Tabs);

this allocates mem. and you do not free it. normally, I do
  data:= ATTabs1.GetTabData(nIndex);
  data.Caption:= 'smth';

chrv:
Thanks for quick reply.

Your code is fine to change Tab caption but what about (dynamically) creating a new tab  (like in my little example program) ?

Alextp:
Method TATTabs.AddTab will do that alloc of Data.

chrv:
I coverted my little demo with your suggestion.
It seems it does not change anything. Still memory leak

heaptrc : 1 unfreed memory blocks


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1;{$mode objfpc}{$H+}interfaceuses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, attabs;type  TForm1 = class(TForm)    Button1: TButton;    Edit1: TEdit;    procedure Button1Click(Sender: TObject);    procedure FormCreate(Sender: TObject);  private  public    AT : TATTabs;  end; var  Form1: TForm1; implementation{$R *.lfm}procedure TForm1.FormCreate(Sender: TObject);begin  AT := TATTabs.Create(Form1);  AT.parent := self;  AT.Align:=alTop;end;procedure TForm1.Button1Click(Sender: TObject);//var//  aTab : TATTabData;begin  AT.AddTab(-1,Edit1.Text);  //aTab := TATTabData.Create(AT.Tabs);  //aTab.TabCaption:=Edit1.Text;end;end.      

More information :
1) if  Edit.text ='' => no memory leak   
2) AT.AddTab(-1,'XXX') => no memory leak

Navigation

[0] Message Index

[#] Next page

Go to full version