Hi Jeremy,

Thank you for the reply, I appreciate the amount of time and effort you have put into osgWidget library over the years.

On 4/15/2013 2:07 PM, Jeremy Moles wrote:
On 04/15/2013 12:37 PM, Judson Weissert wrote:
Hello,

I have been experimenting with the osgWidget library recently, and came across what I believe to be a memory leak. I added a break point to the osgWidget::Callback destructor, and it is never called when running the osgwidgetcanvas example program (the constructor is called a number of times).

The osgWidget::EventInterface::CallbackList typedef line in osg/include/osgWidget/EventInterface is:

typedef std::list<osg::observer_ptr<Callback> > CallbackList;

Therefore, the osgWidget::EventInterface object is not managing the callback's memory. Clients could make the mistake of passing in a temporary ref_ptr which would then go out of scope before the callback is used, or if the client passes in an unmanaged pointer (like in the osgWidget examples), there will be a memory leak unless the caller explicitly deallocates the callback at some point in the future after the callback is no longer associated with the scene.

Should the CallbackList type be a std::list <osg::ref_ptr <Callback>> instead?

I just checked this as well, and you appear to be correct. I'm trying to remember what the INTENTION was, but its been so long I can't recall.

I know the feeling :) I am having difficulties trying to figure out the likelihood of circular references if the type is switched from observer_ptr to ref_ptr. I noticed that there are some clients that call the osgWidget::Callback constructor and pass "this" as the obj argument. That is, the callback IS an osgWidget::Window. Currently, I am not thinking clearly enough to identify the repercussions of the aforementioned behavior if the callbacks were stored as a ref_ptr. See osgwidgetnotebook for example.

Regards,

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

Reply via email to