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.
Thanks,

Judson
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to