[gclist] Re: ref-counting performance cost

Mark Hamburg mhamburg@Adobe.COM
Mon, 4 Sep 2000 11:06:52 -0700


>Date: Sun, 3 Sep 100 08:47:32 -0700 (PDT)
>From: "Henry G. Baker" <hbaker@netcom.com>
>Subject: Re: [gclist] ref-counting performance cost
>
>> I've definitely seen memory, files, and windows dealt with using all
>> three approaches more frequently than reference counting.  With good
>> reason:  all three have much better performance than reference counting
>> and are usually easier to implement correctly, even if they don't apply
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Yes and no.

Reference counting falls victim to cycles. It also falls victim to
programmers trying to "optimize" it.

On the other hand, you can implement reference counting with a few C++
templates and have it work with just about any compiler. (Okay. So, trying
to make the pointers work for casting starts giving some compilers fits.)
This is without special knowledge of the complier or the runtime
environment.

Reference counting also works cleanly with C++ destructors.

The performance of reference counting is lackluster (though generally
fairly smooth).  There are cases it doesn't handle. But it's portable.

Mark