[fpc-pascal] A serious Memleak using delegates/implements (was: Delegate Interface class does not seem to be referenced counted)
Marcos Douglas
md at delfire.net
Thu Oct 6 17:11:20 CEST 2016
On Thu, Oct 6, 2016 at 11:57 AM, Graeme Geldenhuys
<mailinglists at geldenhuys.co.uk> wrote:
> Hello Marcos,
>
> On 2016-10-06 at 11:25, Marcos Douglas wrote:
>
>> you need to declarate
>> two variables to do one job.
>> I don't like that and I think shouldn't be necessary.
>
> Well, to be fair, that example is not representative of a real-world
> application. In a real-world app, I would not declare and release
> objects and interface references like than - in the same procedure.
Yes of course, I know.
You will do some like that:
constructor TFoo.Create;
begin
FTheObject := TBar.Create; // implements ITheObject
end;
destructor TFoo.Destroy;
begin
FTheObject.Free;
end;
procedure TFoo.Execute;
begin
CallSomethingThatAcceptsAnInterface(FTheObject);
end;
Nothing wrong. But you needs to create TFoo and manage it.
Regards,
Marcos Douglas
More information about the fpc-pascal
mailing list