John Carmack applauds D's pure attribute

deadalnix deadalnix at gmail.com
Sun Feb 26 07:28:01 PST 2012


Le 25/02/2012 23:55, Walter Bright a écrit :
> On 2/25/2012 2:08 PM, Paulo Pinto wrote:
>> Most standard compiler malloc()/free() implementations are actually
>> slower than
>> most advanced GC algorithms.
>
> Most straight up GC vs malloc/free benchmarks miss something crucial. A
> GC allows one to do substantially *fewer* allocations. It's a lot faster
> to not allocate than to allocate.
>
> Consider C strings. You need to keep track of ownership of it. That
> often means creating extra copies, rather than sharing a single copy.
>
> Enter C++'s shared_ptr. But that works by, for each object, allocating a
> *second* chunk of memory to hold the reference count. Right off the bat,
> you've got twice as many allocations & frees with shared_ptr than a GC
> would have.

True, but the problem of video game isn't how much computation you do to 
allocate, but to deliver a frame every few miliseconds. In most cases, 
it worth spending more in allocating but with a predictable result than 
let the GC does its job.

I wonder how true this will become with multicore and possibility of a 
100% concurrent GC.


More information about the Digitalmars-d mailing list