> Using ref_ptr's is far cheaper than a garbage collector we 
> don't have (... until ISO C++ 2009 ?).
> osg::observer_ptr<> could be used to solve the problem, but 
> you can also simply try to avoid circular references... how ? 
> Well, you could try to define an object to be "slave" of 
> another one. For instance, if 'B' is slave, then A has a 
> ref_ptr<> to B, and B has only a raw pointer (A*). In most 
> cases it's enough because the raw pointer is used only when A 
> is allocated.

That's how I'd handle it.

The posted code would behave the same for any type of reference-counted
memory management system, I imagine, so isn't really an issue with OSG
ref_ptr<> classes. It's simply an aspect of the algorithm, which programmers
must be aware of and be careful to avoid.

Or, to put it another way: "I went to the doctor and said, 'hey doc, it
hurts when I do this' and he replied 'don't do that'". :-)
   -Paul

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to