Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Reference counting in C++

Reply
Thread Tools

Reference counting in C++

 
 
Kalle Rutanen
Guest
Posts: n/a
 
      05-07-2005
Hello

I implemented reference counting in my program, and found out many
problems associated with it. I wonder if the following problems can be
solved automatically rather manually ?

1. In its member function, an object manages to destroy last
reference to itself and thus destructs before the end of the member
function.

In attached counted body, this can be solved manually by taking a
reference to itself in the beginning of the function. Automatically?
What about in detached counted body?

2. An object is referenced during its constructor (for example in
calling other member functions). Object is destroyed before end of the
constructor function, because there can't be any references to it yet
(assuming the reference to it was not stored).

In attached counted body, this can be solved manually by creating an
object that in its constructor adds the reference count and in its
destructor subtracts the reference count, without deleting the object if
count falls to zero. Automatically? What about in detached counted body?

3. An object with static or automatic lifetime is referenced.
4. A reference counted object is used through a pointer.

These two are something that I think that can't be solved. One must just
inform the code user to not to do this.

5. Object's pointer is assigned to more than one reference.

Clearly attached counted body solution does not have this problem, but
how to solve this with detached counted body ?

6. Program contains cyclic references.

7. When reference counting is not used, the machinery is still
present.

This is a problem with attached counted body.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Reference counting and API (const reference vs pointer oriented) mathieu C++ 8 08-31-2008 09:05 AM
counting up instead of counting down edwardfredriks Javascript 6 09-07-2005 03:30 PM
reference counting Tony Johansson C++ 4 05-23-2005 01:28 PM
reference counting and PyTuple_SetItem Anne Wilson Python 0 06-10-2004 04:13 PM
flyweight reference counting ash C++ 1 10-24-2003 10:40 AM



Advertisments