On 6/30/2013 12:35 PM, Michel Fortin wrote:
> Le 25-juin-2013 à 17:00, Walter Bright a écrit :
>
>> 6. If a class or struct contains RC fields, calls to Release() for those
fields will
>> be added to the destructor, and a destructor will be created if one doesn't
exist already.
> Another thing to note that the above is dangerous if the destructor is called
from the GC and RC objects are allocated from GC memory. Referenced objects
might already have been destroyed and you'll be calling Release() on them. This
will happen when the GC releases a cycle.
>
Amended as:
6. If a class or struct contains RC fields, calls to Release() for those fields
will
be added to the destructor, and a destructor will be created if one doesn't
exist already.
Release() implementations should take care to not destroy objects that are
already destroyed,
which can happen if the objects are allocated on the GC heap and the GC removes
a cycle of
refcounted objects.