Boost logo

Boost Users :

From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2008-07-31 18:00:33


Alexander Gutenev <gutenev <at> gmail.com> writes:

>
> > You confuse thing a bit I believe. The over head is not caused so much by
> > the
> > extra object itself as by the pointer to this object that have to reside
> > inside
> > every shared_ptr doubling it's size effectively.
> >
> > Gennadiy
>
> It depends, I think. Assume shared_ptr is used as an easy way to deal with
> polymorphic objects, like putting them into std::vector. Then most of the
> pointers would be unique. So vector data size is doubled, but this is not
> the most overhead. The most overhead is counter and deleter objects, those
> objects are larger than a single pointer, and each of them is stored in
> dedicated heap block.
> If shared_ptr is used really to share objects, then doubling pointer size
> may cause more overhead than counter and deleter.

Overhead of counter and deleter is exactly the same for both shared_ptr and
intrusive_ptr - one per object (the fact that intrusive_ptr doesn't support
Deleter at the moment is beside the point IMO - it should). Slight difference is
that former is require additional new call.

The only "real" advantage of intrusive_ptr is the size of it's instances

Gennadiy


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net