$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] [string] proposal
From: Peter Dimov (pdimov_at_[hidden])
Date: 2011-01-21 11:19:22
Dean Michael Berris wrote:
> 1. The overhead of maintaining that table of reference counts may be
> significant if you have a lot of strings created in your application.
No table is needed; the reference count is just placed before the string
data in the allocated memory.
> 3. The reference count almost always will be implemented with atomic
> counters to be efficient. In cases where the hardware doesn't support
> these (in embedded environments)
...
Copying the string requires a memory allocation, which also grabs a lock.
You're not likely to have a lock-free allocator if you don't have atomic
operations.
> 2. In the case that you do have strings copied around, consider the case
> in multi-threaded applications where you have different threads running on
> different cores.
Copying the string data outweighs the reference count update because of the
allocation.