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?

Thanks,

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

Reply via email to