[fpc-devel] Assign Self

Micha Nelissen micha at neli.hopto.org
Sat Jul 11 13:47:11 CEST 2009


Micha Nelissen wrote:
> procedure tcontractform.add;
> begin
>   self:=tcontractform.create(owner);
>   self.insert.enabled:=true;
>   self.btnregion.enabled:=true;
>   self.showmodal;
> end;

In this case I guess there is even a "memory leak" in the sense that 
Owner is usually "Application" which is a variable existing for lifetime 
of program. So although this temporary form is freed eventually it takes 
up memory until end of program lifetime AFAICS.

A temporary variable named "LeakedContractForm" would have been much 
clearer then :-P.

Or put Self.Free at the end which is even creepier.

Micha



More information about the fpc-devel mailing list