gc vs explicit
Walter Bright
newshound at digitalmars.com
Thu Dec 7 12:48:57 PST 2006
zz wrote:
> From my point of view these tests are not really nessesary on my side
> since I still continue using D and I belive that someday the memory
> stuff will be optimized.
One thing that is happening is that the C++ code allocates memory, it
never frees it. The same with the D code.
What happens with a garbage collector is it gets new chunks of memory
from the operating system as it needs it. But before it does, it runs a
collection cycle.
So in the D version, it will be running probably several collection
cycles (accomplishing nothing), while the C++ version does not. This
will make the gc version slower.
To get better numbers, one can add calls to gc.disable() and gc.enable()
to tell the gc that there is no point to running a collection cycle for
this section of code.
More information about the Digitalmars-d
mailing list