Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-09

typinfo routine gives memory leak

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Howard Page-Clark

The following (button and memo) program loses 276 bytes heap memory that are not recovered.

unit Unit1;
{$mode objfpc}{$H+}
interface
uses
   Forms, StdCtrls;
type
   TForm1 = class(TForm)
     BGetProperties: TButton;
     Memo1: TMemo;
     procedure BGetPropertiesClick(Sender: TObject);
   end;
var
   Form1: TForm1;
implementation
uses Dialogs, typinfo;
{$R *.lfm}
procedure TForm1.BGetPropertiesClick(Sender: TObject);
var ppl: PPropList;
     pl: TPropList;
     ppi: PPropInfo;
     pi: TPropInfo;
begin
   GetPropList(TEdit, ppl);
   pl := ppl^;
   ppi := pl[0];
   pi := ppi^;
   if PropIsType(TEdit, pi.Name, tkAString) then
   ShowMessageFmt('TEdit''s first PropList entry is %s of
tkAString',[pi.Name]);
end;
end.

Anyone know what I'm doing wrong?

Howard

Reply by email

Martin
to Howard Page-Clark
Howard Page-Clark wrote
The following (button and memo) program loses 276 bytes heap memory that are not recovered.

...

Show quoted text 18 lines
procedure TForm1.BGetPropertiesClick(Sender: TObject); var ppl: PPropList; pl: TPropList; ppi: PPropInfo; pi: TPropInfo; begin GetPropList(TEdit, ppl); pl := ppl^; ppi := pl[0]; pi := ppi^; if PropIsType(TEdit, pi.Name, tkAString) then ShowMessageFmt('TEdit''s first PropList entry is %s of tkAString',[pi.Name]); end; end. Anyone know what I'm doing wrong?

afaik you need to

FreeMem(ppl);

Reply by email

Howard Page-Clark
to Martin
Martin wrote 27 lines
On 20/09/2011 21:59, Howard Page-Clark wrote: > The following (button and memo) program loses 276 bytes heap memory > that are not recovered. > ... > procedure TForm1.BGetPropertiesClick(Sender: TObject); > var ppl: PPropList; > pl: TPropList; > ppi: PPropInfo; > pi: TPropInfo; > begin > GetPropList(TEdit, ppl); > pl := ppl^; > ppi := pl[0]; > pi := ppi^; > if PropIsType(TEdit, pi.Name, tkAString) then > ShowMessageFmt('TEdit''s first PropList entry is %s of > tkAString',[pi.Name]); > end; > > end. > > Anyone know what I'm doing wrong? afaik you need to FreeMem(ppl);

Many thanks

H.

Reply by email