iPhone vs Android

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Thu Sep 15 18:18:28 PDT 2016


On Wed, 14 Sep 2016 13:37:03 +0000, Laeeth Isharc wrote:

> On Wednesday, 14 September 2016 at 13:28:45 UTC, finalpatch wrote:
>> On Tuesday, 13 September 2016 at 18:24:26 UTC, deadalnix wrote:
>>> No you don't, as how often the GC kicks in depend of the rate at which
>>> you produce garbage, which is going to be very low with an hybrid
>>> approach.
>>
>> This is simply not true.
>>
>> Assume in a pure GC program the GC heap can grow up to X Mb before a
>> collection cycle happens, which has to scan X Mb of memory.
>>
>> Now let's say we have a hybrid program that uses 0.5X Mb of RCed memory
>> and 0.5X Mb of GC memory so the total memory consumption is still X Mb.
>> When the GC heap reaches 0.5X Mb, it has to scan both RC and GC memory.
> 
> Could you elaborate?

You can store a pointer to a GC-owned memory block inside an RCed object, 
just like how you can store a pointer to a GC-owned memory block on the 
stack.

There are three ways to handle this:

* Keep a pointer to the GCed object inside GCed memory.
* Tell the GC to pin the object, preventing it from being collected.
* Have the GC scan RCed memory as well as GC-owned memory.


More information about the Digitalmars-d mailing list