Hi
I'm drawing lines between two markers in osgart. So whenever they are moved,
the lines are updated each time.
For this I'm updating an
Code:
osg::ref_ptr<osg::Vec3Array> points
My program crashes after it is run for a several seconds/minutes. I found out
that the following lines cause the issue (commenting those can avoid it)
Code:
points->push_back(StartPoint);
points->push_back(EndPoint);
I assume it is due to a memory leak, eventhough I use points->clear() at the
end.
Here's my code (please note that some lines have been omitted for clarity)
Code:
class CallBackClass: public osg::NodeCallback{
private:
osg::ref_ptr<osg::Vec3Array> points;
osg::ref_ptr<osg::Geometry> beam;
public:
CallBackClass::CallBackClass(){
points = new osg::Vec3Array;
beam = new osg::Geometry;
}
void CallBackClass::operator(){
// osg::Vec3 StartPoint,
// osg::Vec3 EndPoint
points->push_back(StartPoint);
points->push_back(EndPoint);
beam->setVertexArray(points.get());
beam->setColorArray(color.get());
beam->setColorBinding(osg::Geometry::BIND_PER_PRIMITIVE);
beam->addPrimitiveSet(new osg::DrawArrays(GL_LINES,0,2));
points->clear();
}
}
Thanks in advance.
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49088#49088
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org