Re: Thread-safe reference counts.
On 29 mar, 02:58, Ian Collins <ian-n...@hotmail.com> wrote:
Jon Harrop wrote:
Ian Collins wrote:
Jon Harrop wrote:
jason.cipri...@gmail.com wrote:
I have some code where objects are dynamically allocated by some
thread, and then used by multiple threads and freed when they are no
longer needed. I think that reference counting is the most appropriat=
e
way to handle this in my situation.
A concurrent garbage collector is the appropriate way to handle that
situation.
One possible way, reference counted objects work just as well.
They are an order of magnitude slower and leak on cycles.
Nonsense, show us the data.
Well, they obviously leak if cycles are present. And while "an
order of magnitude slower" is obviously false as well, Hans
Boehm has performed a number of benchmarks, and they are slower
in a lot of cases.
A lot depends on how you use dynamic memory. The runtime of a
typical collector depends on the amount of memory actually in
use when the garbage collector runs; the runtime of a typical
manual memory allocator depends on the number of allocations and
frees. An application which uses a lot of small, short lived
objects, and disposes of adequate memory, will run significantly
faster with garbage collection. An application which only
allocates a few, very big object, will run faster with manual
collection or shared pointers.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34