
Alexander
On Wednesday 30 July 2008 16:03 pm, Alexander Gutenev wrote:
I want to use intrusive_ptr as a smart pointer to have reference counting without shared_ptr overhead.
I'm curious, could you be more specific about how your implementation has less overhead than shared_ptr? Do you mean it uses less memory? Compiles faster? Runs faster?
Less memory. The overhead of shared_ptr is allocation of another object which has reference count and deleter object. It is allocated in a separate block, hence memory overhead - that's the most noticeable when I have a lot of pointers to small objects.
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