Mac Apps That Use Garbage Collection Must Move to ARC

Benjamin Thaut via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 26 13:15:08 PST 2015


Am 26.02.2015 um 21:39 schrieb Walter Bright:
> On 2/25/2015 1:27 PM, Benjamin Thaut wrote:
>> You seeing this completely one sided. Even if write barries make code
>> slower by
>> 10% its a non issue if the GC collections get faster by 10% as well.
>> Then in
>> average the program will run at the same speed.
>
> You'll be paying that 10% penalty for every write access, not just for
> GC data. D is not Java in that D has a lot of objects that are not on
> the GC heap. Tradeoffs appropriate for Java are not necessarily
> appropriate for D.

Write barries only have to be generated for writes to pointers through 
pointers. So you are not paying a penality for every write.

class Bar
{
   int x;
   Bar other;

   void method()
   {
     x = 5; // no write barrier
     other = this; // write barrier
   }
}

Also the following code will not generate a single write barrier:

void someFunc(uint[] ar)
{
   for(uint* it = someArray.ptr; it < ar.ptr + ar.length; it++)
   {
     *it = 5;
   }
}


More information about the Digitalmars-d mailing list