[fpc-devel] performance tests: reference counted vs non-reference counted
Luiz Americo Pereira Camara
pascalive at bol.com.br
Fri Nov 16 13:06:50 CET 2007
Graeme Geldenhuys wrote:
> procedure TMyApplication.TestRefCountedObjects;
> var
> LO: TInterfacedObject;
> LStart: Cardinal;
> LCount: Cardinal;
> i: integer;
> begin
> LCount := 0;
> LStart := tiGetTickCount;
> while tiGetTickCount - LStart < (CTestRunTime * 1000) do
> begin
> LO := TInterfacedObject.Create;
> Inc(LCount);
> end;
> Log(Format('%s iterations in %d seconds (reference counting)',
> [IntToStr(LCount), CTestRunTime]));
> end;
>
>
A single program like the below leaks memory. To the object be freed
automatically is necessary to declare Obj as IUnknown.
I wonder if your test is leaking memory.
Luiz
program asmIntf;
{$Mode ObjFpc}
procedure DoIt;
var
Obj: TInterfacedObject;
begin
Obj := TInterfacedObject.Create;
end;
begin //Main
DoIt;
end.
More information about the fpc-devel
mailing list