ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
[boost] RFC: combine conserve+shared_ptr advantages
by Larry Evans other posts by this author
Aug 11 2002 12:10PM messages near this date
Re: [boost] Re: Re: Threads & Exceptions | [boost] New Boost Test Library updated and merged in main branch
Some of the advantages of shared_ptr gc are:
    1) recovery resources as soon as they become unreachable
    2) diagnosis of dangling pointers (by the weak_ptr<T> ::get return value)
Some of the advantages of conservative gc
(e.g. http://www.hpl.hp.com/personal/Hans_Boehm/gc/) are:
     1) Lower memory overhead:
          a) 1 mark flag per allocated object
          b) whatever extra allocation overhead required
               to traverse the heap.
      2) Lower time overhead, i.e. each pointer assignment
          doesn't update at least 2 reference count values
          (in the case of weak_ptr::operator= )
          or sometime 4 reference count values
          (in the case of shared_ptr::operator=).

The advantage of shared_ptr immediate recovery is especially
important when an unreachable object contains a scarce resource
such as file handle or database access.

I'm proposing that a compromise be implemented that combines
the advantages of both.  More specifically, just retain the
strong reference count and let the conservative collector recover
memory.  That way, only the strong reference count needs updating.
When it drops to 0, the resources (other than memory) are released
by a call to the objects DTOR.  The memory recovery is delayed
by the conservative collector  until it's actually needed.

Comments about gotcha's or other advantages and disadvantages
welcome.


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved