On Wed, 23 Oct 2002 20:18:59 +0200, Dejan Jelovic <[EMAIL PROTECTED]> wrote:

>Patrick Steele wrote:
>
>> > What I can't understand why reference couting wasn't
>> > implemented in CLI as a standard facility. A [Counted]
>> > attribute would do the trick nicely.
>> > ...
>>
>> See:
>>
>>
>http://discuss.develop.com/archives/wa.exe?A2=ind0010a&L=dotnet&P=39459
>
>I've seen Brian's argument, and they make sense if you are discussing
>reference counting vs. garbage collection. But what I am saying is that
>_optional_ reference counting could be implemented _on top_ of garbage
>collection for those interfaces,
>classes and references that are marked with the (hypotetical) [Counted]
>attribute.
>
>That could be used to ensure that Dispose() is called when the last
>[Counted] reference is destroyed, as a way to reclaim handles and other
>resources. Then later the garbage collector would come and reclaim the
>memory.

Brian addresses your exact point regrading "why not just mark those objects
you wish to have ref counting"?  Problem is that if a non-ref counted
object holds a reference to your ref-counted object, your ref count wont
decrement to 0 until the non-ref counted object gets GC'd.  Thus, this
circumvents all of what you were trying to accomplish by implementing ref
counting.

>Dejan
>
>You can read messages from the Advanced DOTNET archive, unsubscribe from
Advanced DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced 
DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to