[fpc-devel] performance tests: reference counted vs non-reference counted

Luiz Americo Pereira Camara pascalive at bol.com.br
Fri Nov 16 13:42:51 CET 2007


Graeme Geldenhuys wrote:
> On 16/11/2007, Luiz Americo Pereira Camara <pascalive at bol.com.br> wrote:
>   
>> 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.
>>     
>
> That was an oversight, thanks!  Point taken, I was using interfaced
> objects incorrectly.
>
> Yet in the last few test modifications, I explicitly free both
> Reference Counted and non-Reference Counted objects, so that shouldn't
> cause memory leaks.
>
>
> With all these tests, we have cleared up a few issues.  One still
> outstanding is why TInterfacedObject performs better that TObject
> using FPC?
>   
A tip: create a small app (like i provided) with interfaced (with 
automatic and manual free) and not interfaced objects and compile with 
-al. This will create a *.s file with the assembly code.

Another tip: if your gettickcount implementation is not using high 
definition counter (TSC), try using TZentimer of cpu unit 
(http://members.yline.com/~tom_at_work/index.html) or EpikTimer (from wiki)

PS: I was considering using Interfaced objects in a project but gave up 
after seeing the asm code.

Luiz



More information about the fpc-devel mailing list