[webkit-dev] std::shared_ptr?

Benjamin Poulain benjamin at webkit.org
Sat Oct 26 20:11:50 PDT 2013


On 10/26/13, 8:51 PM, Brendan Long wrote:
> One of the answers on this Stack Overflow question
> <http://stackoverflow.com/questions/3628081/shared-ptr-horrible-speed>
> suggests that we can fix the memory issue by using `making_shared`:
> 
>> *use* |make_shared|
> <http://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared> *to
> allocate them*, because (unfortunately) the normal constructor allocates
> two different blocks: one for the object and one for the counter and
> deleter.
> 
> Unfortunately, it looks like
> <http://nerds-central.blogspot.com/2012/03/sharedptr-performance-issues-and.html>
> they're really slow because they're thread-safe, but that may also apply
> to RefPtr.

RefPtr is not thread-safe.

The count itself is maintained by the objects, not the smart pointer.
The vast majority of objects are not thread-safe either due to obvious
performance problems.

Benjamin


More information about the webkit-dev mailing list