
31 Jul
2008
31 Jul
'08
7:22 p.m.
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.