On heap segregation, GC optimization and @nogc relaxing

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 14 13:59:46 PST 2014


On Friday, 14 November 2014 at 11:46:51 UTC, Marc Schütz wrote:
> On Thursday, 13 November 2014 at 22:12:22 UTC, deadalnix wrote:
>> You need a set of root from the TL heap. The trick being to
>> consider everything that is allocated AFTER you get the roots 
>> as
>> automatically alive (you'll collect this in the next collection
>> cycle).
>>
>> That way, new allocated chunk that have reference in the TL 
>> heap
>> will be kept alive, even if you don't know about the roots.
>>
>> You'll find plenty of information about the details if look 
>> into
>> GC for ML family languages.
>
> Consider this:
>
>     auto i = new immutable(int);
>     immutable(int)* a, b;
>     b = i;
>     // GC kicks in here, scans `a` (== null)
>     a = b;
>     b = null;
>     // GC goes on, scans `b` (== null)
>     // => whoops, no reference to *i
>
> Here, a and b are on the stack or in registers. They could also 
> be on the TL heap.

That is a well covered subject and told you what to google for as
well as the basic approach. Your example here simply told me you
haven't done your homework before posting.

Please go look into scientific documentation about GC for ML
languages.


More information about the Digitalmars-d mailing list