An exegesis of Walter's reference counted slice

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 24 12:08:04 PST 2015


On Tue, 24 Feb 2015 14:55:14 -0500, Steven Schveighoffer wrote:

> Note, you need to GC.addRange all the elements if the type has
> references, or else you cannot have GC pointers in the array. For
> example, an array of class references could potentially result in those
> references being collected before the array is gone.

heh. yes, i hit this in my `iv.steam.PartialStream` implementation. those 
occasional crashes was nasty.

> Ironically, if those elements are references, but are reference counted
> references, then you wouldn't need to addRange. An interesting
> problem...

actually, it's safe to add GC roots and regions that contains no GC 
references. it's a little slowdown, as GC must scan that area, but 
nothing bad happens.

yet you are right, there should be some method to distinguish "gc-
agnostic" types. and compiler should be able to infer that...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150224/5dd278ec/attachment.sig>


More information about the Digitalmars-d mailing list