On Mon, 28 Apr 2008, Miguel Angel Marchuet wrote:
> more simple test to see the problem:
> Harbour  looses 38.571 Bytes in 9.25 seconds
> xHarbour looses 56.956 Bytes in 4.83 seconds

Miguel there is no memory leak at all in this test.
Your program reports memory difference because you
forgot to count the size of TGET class object and
TGET class definition which is allocated at first
call to GetNew(). If you want to fix it then add:
     GetNew()
before:
>    nTime := Seconds()
>    nMem := Memory( HB_MEM_USED )
>    ao := {}

> Why Harbour is more slow ?

1. These test uses expensively GT output and this is
   the biggest source of delay.
2. It will depend on memory manger used by CRTL and how efficently
   it can detect memory reallocation and enable build in preallocation
   code - of ourse if it has sth like that.
   xHarbour uses it's own prealocation code for arrays and when you
   make aadd() then it increase internally the array size more then
   requested 1 item and on next AADD() calla it resuses it. You can
   see it in your test that the allocated memory size is not increased
   in each loop. It can greatly increase the speed of aadd() operation
   if CRTL compiler does not have it's own optimizations. Though in
   thise case in my Linux box GLIBC works better then xHarbour prealocated
   code so Harbour without its own prealocation code is faster (3.13 sec.)
   then xHarbour (3.64). I guess you are using BCC. Anyhow it will be
   good to add array preallocation to Harbour in the future. In the way
   like it was done in xHarbour it's only few lines but I'd like to
   join this modification with some others so I'm leaving it for the
   future.

> Why xHarbour loose more memory ?
> Why 2 compilers loose memory ?

Neither Harbour nor xHarbour lose memory in this test and only
you forgot to calculate the size necessary to store TGET class
definition in [x]Harbour internals in your test.

best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to