Boost logo

Boost Users :

From: Alexander Gutenev (gutenev_at_[hidden])
Date: 2008-07-31 15:22:41


> 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.


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