|
Boost : |
From: Greg Colvin (Gregory.Colvin_at_[hidden])
Date: 2002-09-04 14:42:15
At 06:30 AM 9/4/2002, Larry Evans wrote:
>Philippe A. Bouchard wrote:
>
>>Philippe A. Bouchard wrote:
>>
>>
>[...]
>
>>What if instead we use this header:
>>
>>struct placed_ptr_header
>>{
>> int m_count;
>> int m_stacked; // Could count # of times it is referenced on stack
>>};
>>
>>m_stacked would be decremented each time a pointer allocated on the stack is destroyed or reset()ed. This counter could be spreaded all around the pointer diagram on the heap and could call free() when the pointer is the last one on the stack taking care of the object (stack or data segment).
>Looks much better.
>
>However, there are other problems:
>
>1) These, let's call them "root" pointers (to avoid deciding
>whether to call them stack of static), must be stored in some container in
>available to the collector in order to do the collection.
>The root pointer must also be removed from
>same when m_stacked becomes 0. If map is used, that's a big time hit when many
>short-lived shared_ptrs are used (as is often the case). Greg had a faster
>method.
Typically one manages the heap in such a way that it is fast and easy
to traverse all the headers.
>2) m_stacked will not be incremented for each placed_ptr in, e.g.:
>
>vector<placed_ptr<T> > x1;
>vector<vector<placed_ptr<T> > > x2;
>..
>
>because the "real" root pointers are those starting the vectors.
>
>
>_______________________________________________
>Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk