problem with freeing Tlist

Posted by Reynir Svavarsson on September 12, 2006

Hi. Please if you could comment... when I read value out of the database that is access in this case, Tlist canīt be freed of memory, and when I press this button many times to update list, the memory grow big time until out of mem.. But when I just use string instead of reading from database, everything works OK..

unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, DB, ADODB, DBTables;
type
  TForm1 = class(TForm)
    ADOConnection1: TADOConnection;  
    ADOQsongs2: TADOTable;  
    Button4: TButton;  
    procedure Button4Click(Sender: TObject);  
    procedure FormShow(Sender: TObject); 
  private  { Private declarations } 
  public  { Public declarations } 
  end;  
  Ttest = class 
    Name : string; 
  end;
var 
  Form1: TForm1;  
  Songlist : Tlist; 
  NewMemMgr: TMemoryManager;
  
implementation

uses Unit2, Unit3;
{$R *.dfm}

procedure TForm1.Button4Click(Sender: TObject);
var
  song: Ttest;
  I: integer;
  artist :string;
begin
  songlist.free;
  songlist := Tlist.Create;
  for i := 0 to 500000 do begin
    song := Ttest.create;
    //song.name := 'artist';
    song.name := ADOQsongs2.FieldValues['artist'];
    songlist.add(song);
    song.free;
  end;
end;

end.

Related articles

       

Follow Ups